cmd

package
v0.0.0-...-51cc7b5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdapterBase

type AdapterBase struct {
	*server.CustomMetricsAdapterServerOptions

	// Name is the name of the API server.  It defaults to custom-metrics-adapter
	Name string

	// RemoteKubeConfigFile specifies the kubeconfig to use to construct
	// the dynamic client and RESTMapper.  It's set from a flag.
	RemoteKubeConfigFile string
	// DiscoveryInterval specifies the interval at which to recheck discovery
	// information for the discovery RESTMapper.  It's set from a flag.
	DiscoveryInterval time.Duration

	// FlagSet is the flagset to add flags to.
	// It defaults to the normal CommandLine flags
	// if not explicitly set.
	FlagSet *pflag.FlagSet

	// OpenAPIConfig
	OpenAPIConfig *openapicommon.Config
	// contains filtered or unexported fields
}

AdapterBase provides a base set of functionality for any custom metrics adapter. Embed it in a struct containing your options, then:

- Use Flags() to add flags, then call Flags().Parse(os.Argv) - Use DynamicClient and RESTMapper to fetch handles to common utilities - Use WithCustomMetrics(provider) and WithExternalMetrics(provider) to install metrics providers - Use Run(stopChannel) to start the server

All methods on this struct are idempotent except for Run -- they'll perform any initialization on the first call, then return the existing object on later calls. Methods on this struct are not safe to call from multiple goroutines without external synchronization.

func (*AdapterBase) ClientConfig

func (b *AdapterBase) ClientConfig() (*rest.Config, error)

ClientConfig returns the REST client configuration used to construct clients for the clients and RESTMapper, and may be used for other purposes as well. If you need to mutate it, be sure to copy it with rest.CopyConfig first.

func (*AdapterBase) Config

func (b *AdapterBase) Config() (*apiserver.Config, error)

Config fetches the configuration used to ulitmately create the custom metrics adapter's API server. While this method is idempotent, it does "cement" values of some of the other fields, so make sure to only call it just before `Server` or `Run`. Normal users should not need to call this method -- it's for advanced use cases.

func (*AdapterBase) DiscoveryClient

func (b *AdapterBase) DiscoveryClient() (discovery.DiscoveryInterface, error)

DiscoveryClient returns a DiscoveryInterface suitable to for discovering resources available on the cluster.

func (*AdapterBase) DynamicClient

func (b *AdapterBase) DynamicClient() (dynamic.Interface, error)

DynamicClient returns a dynamic Kubernetes client capable of listing and fetching any resources on the cluster.

func (*AdapterBase) Flags

func (b *AdapterBase) Flags() *pflag.FlagSet

Flags returns the flagset used by this adapter. It will initialize the flagset with the minimum required set of flags as well.

func (*AdapterBase) Informers

Informers returns a SharedInformerFactory for constructing new informers. The informers will be automatically started as part of starting the adapter.

func (*AdapterBase) InstallFlags

func (b *AdapterBase) InstallFlags()

InstallFlags installs the minimum required set of flags into the flagset.

func (*AdapterBase) RESTMapper

func (b *AdapterBase) RESTMapper() (apimeta.RESTMapper, error)

RESTMapper returns a RESTMapper dynamically populated with discovery information. The discovery information will be periodically repopulated according to DiscoveryInterval.

func (*AdapterBase) Run

func (b *AdapterBase) Run(stopCh <-chan struct{}) error

Run runs this custom metrics adapter until the given stop channel is closed.

func (*AdapterBase) Server

Server fetches API server object used to ulitmately run the custom metrics adapter. While this method is idempotent, it does "cement" values of some of the other fields, so make sure to only call it just before `Run`. Normal users should not need to call this method -- it's for advanced use cases.

func (*AdapterBase) WithCustomMetrics

func (b *AdapterBase) WithCustomMetrics(p provider.CustomMetricsProvider)

WithCustomMetrics populates the custom metrics provider for this adapter.

func (*AdapterBase) WithExternalMetrics

func (b *AdapterBase) WithExternalMetrics(p provider.ExternalMetricsProvider)

WithExternalMetrics populates the external metrics provider for this adapter.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL