config

package
v1.30.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 46 Imported by: 149

Documentation

Overview

Package config contains utilities for managing the kubeadm configuration API.

Index

Constants

This section is empty.

Variables

View Source
var (
	// PlaceholderToken is only set statically to make kubeadm not randomize the token on every run
	PlaceholderToken = bootstraptokenv1.BootstrapToken{
		Token: &bootstraptokenv1.BootstrapTokenString{
			ID:     "abcdef",
			Secret: "0123456789abcdef",
		},
	}
)

Functions

func BytesToInitConfiguration added in v1.14.0

func BytesToInitConfiguration(b []byte, skipCRIDetect bool) (*kubeadmapi.InitConfiguration, error)

BytesToInitConfiguration converts a byte slice to an internal, defaulted and validated InitConfiguration object. The map may contain many different YAML documents. These YAML documents are parsed one-by-one and well-known ComponentConfig GroupVersionKinds are stored inside of the internal InitConfiguration struct. The resulting InitConfiguration is then dynamically defaulted and validated prior to return.

func ChooseAPIServerBindAddress added in v1.12.0

func ChooseAPIServerBindAddress(bindAddress net.IP) (net.IP, error)

ChooseAPIServerBindAddress is a wrapper for netutil.ResolveBindAddress that also handles the case where no default routes were found and an IP for the API server could not be obtained.

func DefaultedInitConfiguration added in v1.14.0

func DefaultedInitConfiguration(versionedInitCfg *kubeadmapiv1.InitConfiguration, versionedClusterCfg *kubeadmapiv1.ClusterConfiguration, opts LoadOrDefaultConfigurationOptions) (*kubeadmapi.InitConfiguration, error)

DefaultedInitConfiguration takes a versioned init config (often populated by flags), defaults it and converts it into internal InitConfiguration

func DefaultedJoinConfiguration added in v1.14.0

func DefaultedJoinConfiguration(defaultversionedcfg *kubeadmapiv1.JoinConfiguration, opts LoadOrDefaultConfigurationOptions) (*kubeadmapi.JoinConfiguration, error)

DefaultedJoinConfiguration takes a versioned JoinConfiguration (usually filled in by command line parameters), defaults it, converts it to internal and validates it

func DefaultedResetConfiguration added in v1.28.0

func DefaultedResetConfiguration(defaultversionedcfg *kubeadmapiv1.ResetConfiguration, opts LoadOrDefaultConfigurationOptions) (*kubeadmapi.ResetConfiguration, error)

DefaultedResetConfiguration takes a versioned ResetConfiguration (usually filled in by command line parameters), defaults it, converts it to internal and validates it

func DefaultedStaticInitConfiguration added in v1.21.0

func DefaultedStaticInitConfiguration() (*kubeadmapi.InitConfiguration, error)

DefaultedStaticInitConfiguration returns the internal InitConfiguration with static defaults.

func DefaultedUpgradeConfiguration added in v1.30.0

func DefaultedUpgradeConfiguration(defaultversionedcfg *kubeadmapiv1.UpgradeConfiguration, _ LoadOrDefaultConfigurationOptions) (*kubeadmapi.UpgradeConfiguration, error)

DefaultedUpgradeConfiguration takes a versioned UpgradeConfiguration (usually filled in by command line parameters), defaults it, converts it to internal and validates it

func DocMapToUpgradeConfiguration added in v1.30.0

func DocMapToUpgradeConfiguration(gvkmap kubeadmapi.DocumentMap) (*kubeadmapi.UpgradeConfiguration, error)

DocMapToUpgradeConfiguration converts documentMap to an internal, defaulted and validated UpgradeConfiguration object. The map may contain many different YAML documents. These YAML documents are parsed one-by-one and well-known ComponentConfig GroupVersionKinds are stored inside of the internal UpgradeConfiguration struct. The resulting UpgradeConfiguration is then dynamically defaulted and validated prior to return.

func FetchInitConfigurationFromCluster added in v1.14.0

func FetchInitConfigurationFromCluster(client clientset.Interface, printer output.Printer, logPrefix string, newControlPlane, skipComponentConfigs bool) (*kubeadmapi.InitConfiguration, error)

FetchInitConfigurationFromCluster fetches configuration from a ConfigMap in the cluster

func GetNodeRegistration added in v1.24.0

func GetNodeRegistration(kubeconfigFile string, client clientset.Interface, nodeRegistration *kubeadmapi.NodeRegistrationOptions) error

GetNodeRegistration returns the nodeRegistration for the current node

func LoadInitConfigurationFromFile added in v1.14.0

func LoadInitConfigurationFromFile(cfgPath string, opts LoadOrDefaultConfigurationOptions) (*kubeadmapi.InitConfiguration, error)

LoadInitConfigurationFromFile loads a supported versioned InitConfiguration from a file, converts it into internal config, defaults it and verifies it.

func LoadJoinConfigurationFromFile added in v1.14.0

func LoadJoinConfigurationFromFile(cfgPath string, opts LoadOrDefaultConfigurationOptions) (*kubeadmapi.JoinConfiguration, error)

LoadJoinConfigurationFromFile loads versioned JoinConfiguration from file, converts it to internal, defaults and validates it

func LoadOrDefaultInitConfiguration added in v1.14.0

func LoadOrDefaultInitConfiguration(cfgPath string, versionedInitCfg *kubeadmapiv1.InitConfiguration, versionedClusterCfg *kubeadmapiv1.ClusterConfiguration, opts LoadOrDefaultConfigurationOptions) (*kubeadmapi.InitConfiguration, error)

LoadOrDefaultInitConfiguration takes a path to a config file and a versioned configuration that can serve as the default config If cfgPath is specified, the versioned configs will always get overridden with the one in the file (specified by cfgPath). The external, versioned configuration is defaulted and converted to the internal type. Right thereafter, the configuration is defaulted again with dynamic values (like IP addresses of a machine, etc) Lastly, the internal config is validated and returned.

func LoadOrDefaultJoinConfiguration added in v1.14.0

func LoadOrDefaultJoinConfiguration(cfgPath string, defaultversionedcfg *kubeadmapiv1.JoinConfiguration, opts LoadOrDefaultConfigurationOptions) (*kubeadmapi.JoinConfiguration, error)

LoadOrDefaultJoinConfiguration takes a path to a config file and a versioned configuration that can serve as the default config If cfgPath is specified, defaultversionedcfg will always get overridden. Otherwise, the default config (often populated by flags) will be used. Then the external, versioned configuration is defaulted and converted to the internal type. Right thereafter, the configuration is defaulted again with dynamic values (like IP addresses of a machine, etc) Lastly, the internal config is validated and returned.

func LoadOrDefaultResetConfiguration added in v1.28.0

func LoadOrDefaultResetConfiguration(cfgPath string, defaultversionedcfg *kubeadmapiv1.ResetConfiguration, opts LoadOrDefaultConfigurationOptions) (*kubeadmapi.ResetConfiguration, error)

LoadOrDefaultResetConfiguration takes a path to a config file and a versioned configuration that can serve as the default config If cfgPath is specified, defaultversionedcfg will always get overridden. Otherwise, the default config (often populated by flags) will be used. Then the external, versioned configuration is defaulted and converted to the internal type. Right thereafter, the configuration is defaulted again with dynamic values Lastly, the internal config is validated and returned.

func LoadOrDefaultUpgradeConfiguration added in v1.30.0

func LoadOrDefaultUpgradeConfiguration(cfgPath string, defaultversionedcfg *kubeadmapiv1.UpgradeConfiguration, opts LoadOrDefaultConfigurationOptions) (*kubeadmapi.UpgradeConfiguration, error)

LoadOrDefaultUpgradeConfiguration takes a path to a config file and a versioned configuration that can serve as the default config If cfgPath is specified, defaultversionedcfg will always get overridden. Otherwise, the default config (often populated by flags) will be used. Then the external, versioned configuration is defaulted and converted to the internal type. Right thereafter, the configuration is defaulted again with dynamic values Lastly, the internal config is validated and returned.

func LoadResetConfigurationFromFile added in v1.28.0

func LoadResetConfigurationFromFile(cfgPath string, opts LoadOrDefaultConfigurationOptions) (*kubeadmapi.ResetConfiguration, error)

LoadResetConfigurationFromFile loads versioned ResetConfiguration from file, converts it to internal, defaults and validates it

func LoadUpgradeConfigurationFromFile added in v1.30.0

func LoadUpgradeConfigurationFromFile(cfgPath string, _ LoadOrDefaultConfigurationOptions) (*kubeadmapi.UpgradeConfiguration, error)

LoadUpgradeConfigurationFromFile loads UpgradeConfiguration from a file.

func LowercaseSANs added in v1.11.0

func LowercaseSANs(sans []string)

LowercaseSANs can be used to force all SANs to be lowercase so it passes IsDNS1123Subdomain

func MarshalInitConfigurationToBytes added in v1.12.0

func MarshalInitConfigurationToBytes(cfg *kubeadmapi.InitConfiguration, gv schema.GroupVersion) ([]byte, error)

MarshalInitConfigurationToBytes marshals the internal InitConfiguration object to bytes. It writes the embedded ClusterConfiguration object with ComponentConfigs out as separate YAML documents

func MarshalKubeadmConfigObject added in v1.12.0

func MarshalKubeadmConfigObject(obj runtime.Object, gv schema.GroupVersion) ([]byte, error)

MarshalKubeadmConfigObject marshals an Object registered in the kubeadm scheme. If the object is a InitConfiguration or ClusterConfiguration, some extra logic is run

func MigrateOldConfig added in v1.14.0

func MigrateOldConfig(oldConfig []byte, allowExperimental bool, mutators migrateMutators) ([]byte, error)

MigrateOldConfig migrates an old configuration from a byte slice into a new one (returned again as a byte slice). Only kubeadm kinds are migrated.

func NormalizeKubernetesVersion added in v1.9.0

func NormalizeKubernetesVersion(cfg *kubeadmapi.ClusterConfiguration) error

NormalizeKubernetesVersion resolves version labels, sets alternative image registry if requested for CI builds, and validates minimal version that kubeadm SetInitDynamicDefaultssupports.

func SetAPIEndpointDynamicDefaults added in v1.12.0

func SetAPIEndpointDynamicDefaults(cfg *kubeadmapi.APIEndpoint) error

SetAPIEndpointDynamicDefaults checks and sets configuration values for the APIEndpoint object

func SetBootstrapTokensDynamicDefaults added in v1.12.0

func SetBootstrapTokensDynamicDefaults(cfg *[]bootstraptokenv1.BootstrapToken) error

SetBootstrapTokensDynamicDefaults checks and sets configuration values for the BootstrapTokens object

func SetClusterDynamicDefaults added in v1.12.0

func SetClusterDynamicDefaults(cfg *kubeadmapi.ClusterConfiguration, localAPIEndpoint *kubeadmapi.APIEndpoint, nodeRegOpts *kubeadmapi.NodeRegistrationOptions) error

SetClusterDynamicDefaults checks and sets values for the ClusterConfiguration object

func SetInitDynamicDefaults

func SetInitDynamicDefaults(cfg *kubeadmapi.InitConfiguration, skipCRIDetect bool) error

SetInitDynamicDefaults checks and sets configuration values for the InitConfiguration object

func SetJoinControlPlaneDefaults added in v1.13.0

func SetJoinControlPlaneDefaults(cfg *kubeadmapi.JoinControlPlane) error

SetJoinControlPlaneDefaults checks and sets configuration values for the JoinControlPlane object

func SetJoinDynamicDefaults added in v1.11.0

func SetJoinDynamicDefaults(cfg *kubeadmapi.JoinConfiguration, skipCRIDetect bool) error

SetJoinDynamicDefaults checks and sets configuration values for the JoinConfiguration object

func SetNodeRegistrationDynamicDefaults added in v1.12.0

func SetNodeRegistrationDynamicDefaults(cfg *kubeadmapi.NodeRegistrationOptions, controlPlaneTaint, skipCRIDetect bool) error

SetNodeRegistrationDynamicDefaults checks and sets configuration values for the NodeRegistration object

func SetResetDynamicDefaults added in v1.28.0

func SetResetDynamicDefaults(cfg *kubeadmapi.ResetConfiguration, skipCRIDetect bool) error

SetResetDynamicDefaults checks and sets configuration values for the ResetConfiguration object

func ValidateConfig added in v1.28.0

func ValidateConfig(config []byte, allowExperimental bool) error

ValidateConfig takes a byte slice containing a kubeadm configuration and performs conversion to internal types and validation.

func VerifyAPIServerBindAddress added in v1.12.0

func VerifyAPIServerBindAddress(address string) error

VerifyAPIServerBindAddress can be used to verify if a bind address for the API Server is 0.0.0.0, in which case this address is not valid and should not be used.

Types

type LoadOrDefaultConfigurationOptions added in v1.29.0

type LoadOrDefaultConfigurationOptions struct {
	// AllowExperimental indicates whether the experimental / work in progress APIs can be used.
	AllowExperimental bool
	// SkipCRIDetect indicates whether to skip the CRI socket detection when no CRI socket is provided.
	SkipCRIDetect bool
}

LoadOrDefaultConfigurationOptions holds the common LoadOrDefaultConfiguration options.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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