Documentation ¶
Index ¶
- func ReadYAML(data []byte, configScheme *runtime.Scheme, versions ...schema.GroupVersion) (runtime.Object, error)
- func ReadYAMLFile(filename string, configScheme *runtime.Scheme, versions ...schema.GroupVersion) (runtime.Object, error)
- type ControllerBuilder
- func (b *ControllerBuilder) Run(config *unstructured.Unstructured, ctx context.Context) error
- func (b *ControllerBuilder) WithComponentNamespace(ns string) *ControllerBuilder
- func (b *ControllerBuilder) WithHealthChecks(healthChecks ...healthz.HealthChecker) *ControllerBuilder
- func (b *ControllerBuilder) WithInstanceIdentity(identity string) *ControllerBuilder
- func (b *ControllerBuilder) WithKubeConfigFile(kubeConfigFilename string, defaults *client.ClientConnectionOverrides) *ControllerBuilder
- func (b *ControllerBuilder) WithLeaderElection(leaderElection configv1.LeaderElection, defaultNamespace, defaultName string) *ControllerBuilder
- func (b *ControllerBuilder) WithRestartOnChange(stopCh chan<- struct{}, startingFileContent map[string][]byte, files ...string) *ControllerBuilder
- func (b *ControllerBuilder) WithServer(servingInfo configv1.HTTPServingInfo, ...) *ControllerBuilder
- type ControllerCommandConfig
- func (c *ControllerCommandConfig) AddDefaultRotationToConfig(config *operatorv1alpha1.GenericOperatorConfig, configContent []byte) (map[string][]byte, []string, error)
- func (c *ControllerCommandConfig) Config() (*unstructured.Unstructured, *operatorv1alpha1.GenericOperatorConfig, []byte, ...)
- func (c *ControllerCommandConfig) NewCommand() *cobra.Command
- func (c *ControllerCommandConfig) NewCommandWithContext(ctx context.Context) *cobra.Command
- func (c *ControllerCommandConfig) StartController(ctx context.Context) error
- type ControllerContext
- type ControllerFlags
- type StartFunc
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 ¶
func (b *ControllerBuilder) Run(config *unstructured.Unstructured, ctx context.Context) error
Run starts your controller for you. It uses leader election if you asked, otherwise it directly calls you
func (*ControllerBuilder) WithComponentNamespace ¶
func (b *ControllerBuilder) WithComponentNamespace(ns string) *ControllerBuilder
func (*ControllerBuilder) WithHealthChecks ¶
func (b *ControllerBuilder) WithHealthChecks(healthChecks ...healthz.HealthChecker) *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 ¶
func (b *ControllerBuilder) WithServer(servingInfo configv1.HTTPServingInfo, authenticationConfig operatorv1alpha1.DelegatedAuthentication, authorizationConfig operatorv1alpha1.DelegatedAuthorization) *ControllerBuilder
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) AddDefaultRotationToConfig ¶
func (c *ControllerCommandConfig) AddDefaultRotationToConfig(config *operatorv1alpha1.GenericOperatorConfig, configContent []byte) (map[string][]byte, []string, error)
AddDefaultRotationToConfig starts the provided builder with the default rotation set (config + serving info). Use StartController if you do not need to customize the controller builder. This method modifies config with self-signed default cert locations if necessary.
func (*ControllerCommandConfig) Config ¶
func (c *ControllerCommandConfig) Config() (*unstructured.Unstructured, *operatorv1alpha1.GenericOperatorConfig, []byte, error)
Config returns the configuration of this command. Use StartController if you don't need to customize the default operator. This method does not modify the receiver.
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. Deprecated: Use the NewCommandWithContext instead, this is here to be less disturbing for existing usages.
func (*ControllerCommandConfig) NewCommandWithContext ¶
func (c *ControllerCommandConfig) NewCommandWithContext(ctx context.Context) *cobra.Command
NewCommandWithContext 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. The context passed will be passed down to controller loops and observers and cancelled on SIGTERM and SIGINT signals.
func (*ControllerCommandConfig) StartController ¶
func (c *ControllerCommandConfig) StartController(ctx context.Context) error
StartController runs the controller. This is the recommend entrypoint when you don't need to customize the builder.
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 // TerminateOnFiles is a list of files. If any of these changes, the process terminates. TerminateOnFiles []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