cloud-providerk8s.io/cloud-provider/app Index | Files | Directories

package app

import "k8s.io/cloud-provider/app"

Package app implements a server that runs a set of active components. This includes node controllers, service and route controller, and so on.

Index

Constants

const (
	// ControllerStartJitter is the jitter value used when starting controller managers.
	ControllerStartJitter = 1.0
	// ConfigzName is the name used for register cloud-controller manager /configz, same with GroupName.
	ConfigzName = "cloudcontrollermanager.config.k8s.io"
)

Variables

var (
	// ControllersDisabledByDefault is the controller disabled default when starting cloud-controller managers.
	ControllersDisabledByDefault = sets.NewString()

	// AllWebhooks represents the list of all webhook options configured in
	// this package.  This is empty because no webhooks are currently
	// configured in this package.
	AllWebhooks = []string{}

	// DisabledByDefaultWebhooks represents the list of webhooks which must be
	// explicitly enabled. This is empty because no webhooks are currently
	// configured in this package.
	DisabledByDefaultWebhooks = []string{}
)
var DefaultInitFuncConstructors = map[string]ControllerInitFuncConstructor{

	names.CloudNodeController: {
		InitContext: ControllerInitContext{
			ClientName: "node-controller",
		},
		Constructor: StartCloudNodeControllerWrapper,
	},
	names.CloudNodeLifecycleController: {
		InitContext: ControllerInitContext{
			ClientName: "node-controller",
		},
		Constructor: StartCloudNodeLifecycleControllerWrapper,
	},
	names.ServiceLBController: {
		InitContext: ControllerInitContext{
			ClientName: "service-controller",
		},
		Constructor: StartServiceControllerWrapper,
	},
	names.NodeRouteController: {
		InitContext: ControllerInitContext{
			ClientName: "route-controller",
		},
		Constructor: StartRouteControllerWrapper,
	},
}

DefaultInitFuncConstructors is a map of default named controller groups paired with InitFuncConstructor

var WebhooksDisabledByDefault = sets.NewString()

WebhooksDisabledByDefault is the webhooks disabled default when starting cloud-controller managers.

Functions

func ConstructControllerInitializers

func ConstructControllerInitializers(controllerInitFuncConstructors map[string]ControllerInitFuncConstructor, completedConfig *cloudcontrollerconfig.CompletedConfig, cloud cloudprovider.Interface) map[string]InitFunc

ConstructControllerInitializers is a map of controller name(as defined by controllers flag in https://kubernetes.io/docs/reference/command-line-tools-reference/kube-controller-manager/#options) to their InitFuncConstructor. paired to their InitFunc. This allows for structured downstream composition and subdivision.

func ControllerNames

func ControllerNames(controllerInitFuncConstructors map[string]ControllerInitFuncConstructor) []string

ControllerNames indicate the default controller we are known.

func CreateControllerContext

func CreateControllerContext(s *cloudcontrollerconfig.CompletedConfig, clientBuilder clientbuilder.ControllerClientBuilder, stop <-chan struct{}) (genericcontrollermanager.ControllerContext, error)

CreateControllerContext creates a context struct containing references to resources needed by the controllers such as the cloud provider and clientBuilder. rootClientBuilder is only used for the shared-informers client and token controller.

func NewCloudControllerManagerCommand

func NewCloudControllerManagerCommand(s *options.CloudControllerManagerOptions, cloudInitializer InitCloudFunc, controllerInitFuncConstructors map[string]ControllerInitFuncConstructor, controllerAliases map[string]string, additionalFlags cliflag.NamedFlagSets, stopCh <-chan struct{}) *cobra.Command

NewCloudControllerManagerCommand creates a *cobra.Command object with default parameters controllerInitFuncConstructors is a map of controller name(as defined by controllers flag in https://kubernetes.io/docs/reference/command-line-tools-reference/kube-controller-manager/#options) to their InitFuncConstructor. additionalFlags provides controller specific flags to be included in the complete set of controller manager flags

func NewWebhookHandlers

func NewWebhookHandlers(webhookConfigs map[string]WebhookConfig, completedConfig *config.CompletedConfig, cloud cloudprovider.Interface) map[string]WebhookHandler

func ResyncPeriod

func ResyncPeriod(c *cloudcontrollerconfig.CompletedConfig) func() time.Duration

ResyncPeriod returns a function which generates a duration each time it is invoked; this is so that multiple controllers don't get into lock-step and all hammer the apiserver with list requests simultaneously.

func Run

func Run(c *cloudcontrollerconfig.CompletedConfig, cloud cloudprovider.Interface, controllerInitializers map[string]InitFunc, webhooks map[string]WebhookHandler,
	stopCh <-chan struct{}) error

Run runs the ExternalCMServer. This should never exit.

func WebhookNames

func WebhookNames(webhooks map[string]WebhookConfig) []string

Types

type CommandBuilder

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

func NewBuilder

func NewBuilder() *CommandBuilder

func (*CommandBuilder) AddFlags

func (cb *CommandBuilder) AddFlags(additionalFlags cliflag.NamedFlagSets)

func (*CommandBuilder) BuildCommand

func (cb *CommandBuilder) BuildCommand() *cobra.Command

func (*CommandBuilder) RegisterController

func (cb *CommandBuilder) RegisterController(name string, constructor ControllerInitFuncConstructor, aliases map[string]string)

func (*CommandBuilder) RegisterDefaultControllers

func (cb *CommandBuilder) RegisterDefaultControllers()

func (*CommandBuilder) RegisterWebhook

func (cb *CommandBuilder) RegisterWebhook(name string, config WebhookConfig)

func (*CommandBuilder) SetCloudInitializer

func (cb *CommandBuilder) SetCloudInitializer(cloudInitializer InitCloudFunc)

func (*CommandBuilder) SetCmdName

func (cb *CommandBuilder) SetCmdName(name string)

func (*CommandBuilder) SetLongDesc

func (cb *CommandBuilder) SetLongDesc(long string)

func (*CommandBuilder) SetOptions

func (cb *CommandBuilder) SetOptions(options *options.CloudControllerManagerOptions)

func (*CommandBuilder) SetProviderDefaults

func (cb *CommandBuilder) SetProviderDefaults(defaults options.ProviderDefaults)

SetProviderDefaults can be called to change the default values for some options when a flag is not set

func (*CommandBuilder) SetStopChannel

func (cb *CommandBuilder) SetStopChannel(stopCh <-chan struct{})

type ControllerInitContext

type ControllerInitContext struct {
	ClientName string
}

type ControllerInitFuncConstructor

type ControllerInitFuncConstructor struct {
	InitContext ControllerInitContext
	Constructor InitFuncConstructor
}

type InitCloudFunc

InitCloudFunc is used to initialize cloud

type InitFunc

type InitFunc func(ctx context.Context, controllerContext genericcontrollermanager.ControllerContext) (controller controller.Interface, enabled bool, err error)

InitFunc is used to launch a particular controller. It returns a controller that can optionally implement other interfaces so that the controller manager can support the requested features. The returned controller may be nil, which will be considered an anonymous controller that requests no additional features from the controller manager. Any error returned will cause the controller process to `Fatal` The bool indicates whether the controller was enabled.

func StartCloudNodeControllerWrapper

func StartCloudNodeControllerWrapper(initContext ControllerInitContext, completedConfig *cloudcontrollerconfig.CompletedConfig, cloud cloudprovider.Interface) InitFunc

StartCloudNodeControllerWrapper is used to take cloud config as input and start cloud node controller

func StartCloudNodeLifecycleControllerWrapper

func StartCloudNodeLifecycleControllerWrapper(initContext ControllerInitContext, completedConfig *cloudcontrollerconfig.CompletedConfig, cloud cloudprovider.Interface) InitFunc

StartCloudNodeLifecycleControllerWrapper is used to take cloud config as input and start cloud node lifecycle controller

func StartRouteControllerWrapper

func StartRouteControllerWrapper(initContext ControllerInitContext, completedConfig *cloudcontrollerconfig.CompletedConfig, cloud cloudprovider.Interface) InitFunc

StartRouteControllerWrapper is used to take cloud config as input and start route controller

func StartServiceControllerWrapper

func StartServiceControllerWrapper(initContext ControllerInitContext, completedConfig *cloudcontrollerconfig.CompletedConfig, cloud cloudprovider.Interface) InitFunc

StartServiceControllerWrapper is used to take cloud config as input and start service controller

type InitFuncConstructor

type InitFuncConstructor func(initcontext ControllerInitContext, completedConfig *cloudcontrollerconfig.CompletedConfig, cloud cloudprovider.Interface) InitFunc

InitFuncConstructor is used to construct InitFunc

type WebhookConfig

type WebhookConfig struct {
	Path             string
	AdmissionHandler func(*admissionv1.AdmissionRequest) (*admissionv1.AdmissionResponse, error)
}

type WebhookHandler

type WebhookHandler struct {
	Name string
	Path string
	http.Handler
	AdmissionHandler func(*admissionv1.AdmissionRequest) (*admissionv1.AdmissionResponse, error)
	CompletedConfig  *config.CompletedConfig
	Cloud            cloudprovider.Interface
}

func (WebhookHandler) ServeHTTP

func (h WebhookHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

Source Files

builder.go controllermanager.go core.go webhook_metrics.go webhooks.go

Directories

PathSynopsis
app/config
app/testing
Version
v0.32.2 (latest)
Published
Feb 13, 2025
Platform
linux/amd64
Imports
60 packages
Last checked
2 months ago

Tools for package owners.