Documentation ¶
Overview ¶
Package util contains kubeadm utilities.
Index ¶
- Constants
- Variables
- func ArgumentsFromCommand(command []string) []kubeadmapi.Arg
- func ArgumentsToCommand(base []kubeadmapi.Arg, overrides []kubeadmapi.Arg) []string
- func CheckErr(err error)
- func Chroot(rootfs string) error
- func CopyDir(src string, dst string) ([]byte, error)
- func CopyFile(src, dest string) error
- func FormatErrMsg(errs []error) string
- func GetControlPlaneEndpoint(controlPlaneEndpoint string, localEndpoint *kubeadmapi.APIEndpoint) (string, error)
- func GetLocalAPIEndpoint(localEndpoint *kubeadmapi.APIEndpoint) (string, error)
- func GetProxyEnvVars(environment []string) []kubeadmapi.EnvVar
- func GroupVersionKindsFromBytes(b []byte) ([]schema.GroupVersionKind, error)
- func GroupVersionKindsHasClusterConfiguration(gvks ...schema.GroupVersionKind) bool
- func GroupVersionKindsHasInitConfiguration(gvks ...schema.GroupVersionKind) bool
- func GroupVersionKindsHasJoinConfiguration(gvks ...schema.GroupVersionKind) bool
- func GroupVersionKindsHasKind(gvks []schema.GroupVersionKind, kind string) bool
- func GroupVersionKindsHasResetConfiguration(gvks ...schema.GroupVersionKind) bool
- func GroupVersionKindsHasUpgradeConfiguration(gvks ...schema.GroupVersionKind) bool
- func KubernetesIsCIVersion(version string) bool
- func KubernetesVersionToImageTag(version string) string
- func MarshalToYaml(obj runtime.Object, gv schema.GroupVersion) ([]byte, error)
- func MarshalToYamlForCodecs(obj runtime.Object, gv schema.GroupVersion, codecs serializer.CodecFactory) ([]byte, error)
- func MergeKubeadmEnvVars(envList ...[]kubeadmapi.EnvVar) []v1.EnvVar
- func MoveFile(src, dest string) error
- func ParseHostPort(hostport string) (string, string, error)
- func ParsePort(port string) (int, error)
- func ParseTemplate(strtmpl string, obj interface{}) ([]byte, error)
- func SplitYAMLDocuments(yamlBytes []byte) (kubeadmapi.DocumentMap, error)
- func StartTimeUTC() time.Time
- func UniversalUnmarshal(buffer []byte) (runtime.Object, error)
Constants ¶
const ( // DefaultErrorExitCode defines exit the code for failed action generally DefaultErrorExitCode = 1 // PreFlightExitCode defines exit the code for preflight checks PreFlightExitCode = 2 // ValidationExitCode defines the exit code validation checks ValidationExitCode = 3 )
Variables ¶
var ( // ErrExit is an error returned when kubeadm is about to exit ErrExit = errors.New("exit") )
var KubernetesReleaseVersion = kubernetesReleaseVersionDefault
KubernetesReleaseVersion during unit tests equals kubernetesReleaseVersionTest and returns a static placeholder version. When not running in unit tests it equals kubernetesReleaseVersionDefault.
Functions ¶
func ArgumentsFromCommand ¶ added in v1.29.0
func ArgumentsFromCommand(command []string) []kubeadmapi.Arg
ArgumentsFromCommand parses a CLI command in the form "--foo=bar" to an Arg slice. This function's primary purpose is to parse the kubeadm-flags.env file, but can remain unused for some releases.
func ArgumentsToCommand ¶ added in v1.29.0
func ArgumentsToCommand(base []kubeadmapi.Arg, overrides []kubeadmapi.Arg) []string
ArgumentsToCommand takes two Arg slices, one with the base arguments and one with optional override arguments. In the return list override arguments will precede base arguments. If an argument is present in the overrides, it will cause all instances of the same argument in the base list to be discarded, leaving only the instances of this argument in the overrides to be applied.
func CheckErr ¶
func CheckErr(err error)
CheckErr prints a user friendly error to STDERR and exits with a non-zero exit code. Unrecognized errors will be printed with an "error: " prefix.
This method is generic to the command in use and may be used by non-Kubectl commands.
func Chroot ¶ added in v1.12.0
Chroot chroot()s to the new path. NB: All file paths after this call are effectively relative to `rootfs`
func FormatErrMsg ¶ added in v1.9.0
FormatErrMsg returns a human-readable string describing the slice of errors passed to the function
func GetControlPlaneEndpoint ¶ added in v1.14.0
func GetControlPlaneEndpoint(controlPlaneEndpoint string, localEndpoint *kubeadmapi.APIEndpoint) (string, error)
GetControlPlaneEndpoint returns a properly formatted endpoint for the control plane built according following rules: - If the controlPlaneEndpoint is defined, use it. - if the controlPlaneEndpoint is defined but without a port number, use the controlPlaneEndpoint + localEndpoint.BindPort is used. - Otherwise, in case the controlPlaneEndpoint is not defined, use the localEndpoint.AdvertiseAddress + the localEndpoint.BindPort.
func GetLocalAPIEndpoint ¶ added in v1.19.1
func GetLocalAPIEndpoint(localEndpoint *kubeadmapi.APIEndpoint) (string, error)
GetLocalAPIEndpoint parses an APIEndpoint and returns it as a string, or returns and error in case it cannot be parsed.
func GetProxyEnvVars ¶ added in v1.17.0
func GetProxyEnvVars(environment []string) []kubeadmapi.EnvVar
GetProxyEnvVars builds a list of environment variables in order to use the right proxy. Passing nil for environment will make the function use the OS environment.
func GroupVersionKindsFromBytes ¶ added in v1.12.0
func GroupVersionKindsFromBytes(b []byte) ([]schema.GroupVersionKind, error)
GroupVersionKindsFromBytes parses the bytes and returns a gvk slice
func GroupVersionKindsHasClusterConfiguration ¶ added in v1.12.0
func GroupVersionKindsHasClusterConfiguration(gvks ...schema.GroupVersionKind) bool
GroupVersionKindsHasClusterConfiguration returns whether the following gvk slice contains a ClusterConfiguration object
func GroupVersionKindsHasInitConfiguration ¶ added in v1.12.0
func GroupVersionKindsHasInitConfiguration(gvks ...schema.GroupVersionKind) bool
GroupVersionKindsHasInitConfiguration returns whether the following gvk slice contains a InitConfiguration object
func GroupVersionKindsHasJoinConfiguration ¶ added in v1.12.0
func GroupVersionKindsHasJoinConfiguration(gvks ...schema.GroupVersionKind) bool
GroupVersionKindsHasJoinConfiguration returns whether the following gvk slice contains a JoinConfiguration object
func GroupVersionKindsHasKind ¶ added in v1.12.0
func GroupVersionKindsHasKind(gvks []schema.GroupVersionKind, kind string) bool
GroupVersionKindsHasKind returns whether the following gvk slice contains the kind given as a parameter
func GroupVersionKindsHasResetConfiguration ¶ added in v1.28.0
func GroupVersionKindsHasResetConfiguration(gvks ...schema.GroupVersionKind) bool
GroupVersionKindsHasResetConfiguration returns whether the following gvk slice contains a ResetConfiguration object
func GroupVersionKindsHasUpgradeConfiguration ¶ added in v1.30.0
func GroupVersionKindsHasUpgradeConfiguration(gvks ...schema.GroupVersionKind) bool
GroupVersionKindsHasUpgradeConfiguration returns whether the following gvk slice contains a UpgradeConfiguration object
func KubernetesIsCIVersion ¶ added in v1.8.0
KubernetesIsCIVersion checks if user requested CI version
func KubernetesVersionToImageTag ¶ added in v1.8.0
KubernetesVersionToImageTag is helper function that replaces all non-allowed symbols in tag strings with underscores. Image tag can only contain lowercase and uppercase letters, digits, underscores, periods and dashes. Current usage is for CI images where all of symbols except '+' are valid, but function is for generic usage where input can't be always pre-validated.
func MarshalToYaml ¶ added in v1.9.0
MarshalToYaml marshals an object into yaml.
func MarshalToYamlForCodecs ¶ added in v1.9.0
func MarshalToYamlForCodecs(obj runtime.Object, gv schema.GroupVersion, codecs serializer.CodecFactory) ([]byte, error)
MarshalToYamlForCodecs marshals an object into yaml using the specified codec TODO: Is specifying the gv really needed here? TODO: Can we support json out of the box easily here?
func MergeKubeadmEnvVars ¶ added in v1.28.3
func MergeKubeadmEnvVars(envList ...[]kubeadmapi.EnvVar) []v1.EnvVar
MergeKubeadmEnvVars merges values of environment variable slices. The values defined in later slices overwrite values in previous ones.
func ParseHostPort ¶ added in v1.11.0
ParseHostPort parses a network address of the form "host:port", "ipv4:port", "[ipv6]:port" into host and port; ":port" can be eventually omitted. If the string is not a valid representation of network address, ParseHostPort returns an error.
func ParsePort ¶ added in v1.12.0
ParsePort parses a string representing a TCP port. If the string is not a valid representation of a TCP port, ParsePort returns an error.
func ParseTemplate ¶ added in v1.6.0
ParseTemplate validates and parses passed as argument template
func SplitYAMLDocuments ¶ added in v1.12.0
func SplitYAMLDocuments(yamlBytes []byte) (kubeadmapi.DocumentMap, error)
SplitYAMLDocuments reads the YAML bytes per-document, unmarshals the TypeMeta information from each document and returns a map between the GroupVersionKind of the document and the document bytes
func StartTimeUTC ¶ added in v1.31.0
StartTimeUTC returns startTime with its location set to UTC.
Types ¶
This section is empty.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package apiclient contains wrapping logic for Kubernetes API clients.
|
Package apiclient contains wrapping logic for Kubernetes API clients. |
Package config contains utilities for managing the kubeadm configuration API.
|
Package config contains utilities for managing the kubeadm configuration API. |
Package pubkeypin provides primitives for x509 public key pinning in the style of RFC7469.
|
Package pubkeypin provides primitives for x509 public key pinning in the style of RFC7469. |
Package runtime provides the kubeadm container runtime implementation.
|
Package runtime provides the kubeadm container runtime implementation. |