package util

import "k8s.io/kubernetes/cmd/kubeadm/app/util"

Package util contains kubeadm utilities.

Index

Variables

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

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

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 Chroot

func Chroot(rootfs string) error

Chroot chroot()s to the new path. NB: All file paths after this call are effectively relative to `rootfs`

func CopyDir

func CopyDir(src string, dst string) ([]byte, error)

CopyDir copies the content of a folder

func CopyFile

func CopyFile(src, dest string) error

CopyFile copies a file from src to dest.

func GetControlPlaneEndpoint

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

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

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

func GroupVersionKindsFromBytes(b []byte) ([]schema.GroupVersionKind, error)

GroupVersionKindsFromBytes parses the bytes and returns a gvk slice

func GroupVersionKindsHasClusterConfiguration

func GroupVersionKindsHasClusterConfiguration(gvks ...schema.GroupVersionKind) bool

GroupVersionKindsHasClusterConfiguration returns whether the following gvk slice contains a ClusterConfiguration object

func GroupVersionKindsHasInitConfiguration

func GroupVersionKindsHasInitConfiguration(gvks ...schema.GroupVersionKind) bool

GroupVersionKindsHasInitConfiguration returns whether the following gvk slice contains a InitConfiguration object

func GroupVersionKindsHasJoinConfiguration

func GroupVersionKindsHasJoinConfiguration(gvks ...schema.GroupVersionKind) bool

GroupVersionKindsHasJoinConfiguration returns whether the following gvk slice contains a JoinConfiguration object

func GroupVersionKindsHasKind

func GroupVersionKindsHasKind(gvks []schema.GroupVersionKind, kind string) bool

GroupVersionKindsHasKind returns whether the following gvk slice contains the kind given as a parameter

func GroupVersionKindsHasResetConfiguration

func GroupVersionKindsHasResetConfiguration(gvks ...schema.GroupVersionKind) bool

GroupVersionKindsHasResetConfiguration returns whether the following gvk slice contains a ResetConfiguration object

func GroupVersionKindsHasUpgradeConfiguration

func GroupVersionKindsHasUpgradeConfiguration(gvks ...schema.GroupVersionKind) bool

GroupVersionKindsHasUpgradeConfiguration returns whether the following gvk slice contains a UpgradeConfiguration object

func KubernetesIsCIVersion

func KubernetesIsCIVersion(version string) bool

KubernetesIsCIVersion checks if user requested CI version

func KubernetesVersionToImageTag

func KubernetesVersionToImageTag(version string) string

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

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

MarshalToYaml marshals an object into yaml.

func MarshalToYamlForCodecs

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

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 MoveFile

func MoveFile(src, dest string) error

MoveFile moves a file from src to dest.

func ParseHostPort

func ParseHostPort(hostport string) (string, string, error)

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

func ParsePort(port string) (int, error)

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

func ParseTemplate(strtmpl string, obj interface{}) ([]byte, error)

ParseTemplate validates and parses passed as argument template

func SplitConfigDocuments

func SplitConfigDocuments(documentBytes []byte) (kubeadmapi.DocumentMap, error)

SplitConfigDocuments reads the YAML/JSON 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

func StartTimeUTC() time.Time

StartTimeUTC returns startTime with its location set to UTC.

func UniversalUnmarshal

func UniversalUnmarshal(buffer []byte) (runtime.Object, error)

UniversalUnmarshal unmarshals YAML or JSON into a runtime.Object using the universal deserializer.

Source Files

arguments.go chroot_unix.go copy.go copy_unix.go endpoint.go env.go marshal.go starttime.go template.go version.go

Directories

PathSynopsis
cmd/kubeadm/app/util/apiclientPackage apiclient contains wrapping logic for Kubernetes API clients.
cmd/kubeadm/app/util/certs
cmd/kubeadm/app/util/configPackage config contains utilities for managing the kubeadm configuration API.
cmd/kubeadm/app/util/config/strict
cmd/kubeadm/app/util/crypto
cmd/kubeadm/app/util/dryrun
cmd/kubeadm/app/util/errorsPackage errors contains a local implementation of error wrapping with stack traces similar to https://github.com/pkg/errors.
cmd/kubeadm/app/util/etcd
cmd/kubeadm/app/util/image
cmd/kubeadm/app/util/initsystem
cmd/kubeadm/app/util/kubeconfig
cmd/kubeadm/app/util/output
cmd/kubeadm/app/util/patches
cmd/kubeadm/app/util/pkiutil
cmd/kubeadm/app/util/pkiutil/testing
cmd/kubeadm/app/util/pubkeypinPackage pubkeypin provides primitives for x509 public key pinning in the style of RFC7469.
cmd/kubeadm/app/util/runtimePackage runtime provides the kubeadm container runtime implementation.
cmd/kubeadm/app/util/staticpod
cmd/kubeadm/app/util/users
Version
v1.34.0-alpha.1
Published
Jun 16, 2025
Platform
js/wasm
Imports
35 packages
Last checked
33 seconds ago

Tools for package owners.