controllercmd

package
v0.0.0-...-dab26bb Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2019 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadYAML

func ReadYAML(data []byte, configScheme *runtime.Scheme, versions ...schema.GroupVersion) (runtime.Object, error)

ReadYAML decodes a runtime.Object from the provided scheme TODO versions goes away with more complete scheme in 1.11

func ReadYAMLFile

func ReadYAMLFile(filename string, configScheme *runtime.Scheme, versions ...schema.GroupVersion) (runtime.Object, error)

ReadYAMLFile read a file and decodes a runtime.Object from the provided scheme

Types

type ControllerBuilder

type ControllerBuilder struct {
	// contains filtered or unexported fields
}

ControllerBuilder allows the construction of an controller in optional pieces.

func NewController

func NewController(componentName string, startFunc StartFunc) *ControllerBuilder

NewController returns a builder struct for constructing the command you want to run

func (*ControllerBuilder) Run

Run starts your controller for you. It uses leader election if you asked, otherwise it directly calls you

func (*ControllerBuilder) WithHealthChecks

func (b *ControllerBuilder) WithHealthChecks(healthChecks ...healthz.HealthzChecker) *ControllerBuilder

WithHealthChecks adds a list of healthchecks to the server

func (*ControllerBuilder) WithInstanceIdentity

func (b *ControllerBuilder) WithInstanceIdentity(identity string) *ControllerBuilder

WithInstanceIdentity sets the instance identity to use if you need something special. The default is just a UID which is usually fine for a pod.

func (*ControllerBuilder) WithKubeConfigFile

func (b *ControllerBuilder) WithKubeConfigFile(kubeConfigFilename string, defaults *client.ClientConnectionOverrides) *ControllerBuilder

WithKubeConfigFile sets an optional kubeconfig file. inclusterconfig will be used if filename is empty

func (*ControllerBuilder) WithLeaderElection

func (b *ControllerBuilder) WithLeaderElection(leaderElection configv1.LeaderElection, defaultNamespace, defaultName string) *ControllerBuilder

WithLeaderElection adds leader election options

func (*ControllerBuilder) WithRestartOnChange

func (b *ControllerBuilder) WithRestartOnChange(stopCh chan<- struct{}, startingFileContent map[string][]byte, files ...string) *ControllerBuilder

WithRestartOnChange will enable a file observer controller loop that observes changes into specified files. If a change to a file is detected, the specified channel will be closed (allowing to graceful shutdown for other channels).

func (*ControllerBuilder) WithServer

WithServer adds a server that provides metrics and healthz

type ControllerCommandConfig

type ControllerCommandConfig struct {
	// contains filtered or unexported fields
}

ControllerCommandConfig holds values required to construct a command to run.

func NewControllerCommandConfig

func NewControllerCommandConfig(componentName string, version version.Info, startFunc StartFunc) *ControllerCommandConfig

NewControllerConfig returns a new ControllerCommandConfig which can be used to wire up all the boiler plate of a controller TODO add more methods around wiring health checks and the like

func (*ControllerCommandConfig) NewCommand

func (c *ControllerCommandConfig) NewCommand() *cobra.Command

NewCommand returns a new command that a caller must set the Use and Descriptions on. It wires default log, profiling, leader election and other "normal" behaviors.

func (*ControllerCommandConfig) StartController

func (c *ControllerCommandConfig) StartController(ctx context.Context) error

StartController runs the controller

type ControllerContext

type ControllerContext struct {
	ComponentConfig *unstructured.Unstructured

	// KubeConfig provides the REST config with no content type (it will default to JSON).
	// Use this config for CR resources.
	KubeConfig *rest.Config

	// ProtoKubeConfig provides the REST config with "application/vnd.kubernetes.protobuf,application/json" content type.
	// Note that this config might not be safe for CR resources, instead it should be used for other resources.
	ProtoKubeConfig *rest.Config

	// EventRecorder is used to record events in controllers.
	EventRecorder events.Recorder

	// Server is the GenericAPIServer serving healthz checks and debug info
	Server *genericapiserver.GenericAPIServer
	// contains filtered or unexported fields
}

func (ControllerContext) Done

func (c ControllerContext) Done() <-chan struct{}

Done returns a channel which will close on termination.

type ControllerFlags

type ControllerFlags struct {
	// ConfigFile hold the configfile to load
	ConfigFile string
	// KubeConfigFile points to a kubeconfig file if you don't want to use the in cluster config
	KubeConfigFile string
}

ControllerFlags provides the "normal" controller flags

func NewControllerFlags

func NewControllerFlags() *ControllerFlags

NewControllerFlags returns flags with default values set

func (*ControllerFlags) AddFlags

func (f *ControllerFlags) AddFlags(cmd *cobra.Command)

AddFlags register and binds the default flags

func (*ControllerFlags) ToClientConfig

func (f *ControllerFlags) ToClientConfig(overrides *client.ClientConnectionOverrides) (*rest.Config, error)

ToClientConfig given completed flags, returns a rest.Config. overrides are optional

func (*ControllerFlags) ToConfigObj

func (f *ControllerFlags) ToConfigObj() ([]byte, *unstructured.Unstructured, error)

ToConfigObj given completed flags, returns a config object for the flag that was specified. TODO versions goes away in 1.11

func (*ControllerFlags) Validate

func (o *ControllerFlags) Validate() error

Validate makes sure the required flags are specified and no illegal combinations are found

type StartFunc

type StartFunc func(*ControllerContext) error

StartFunc is the function to call on leader election start

Jump to

Keyboard shortcuts

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