...

Package preflight

import "k8s.io/kubernetes/cmd/kubeadm/app/preflight"
Overview
Index

Overview ▾

Index ▾

func GetKubeletVersion(execer utilsexec.Interface) (*version.Version, error)
func RunChecks(checks []Checker, ww io.Writer, ignorePreflightErrors sets.Set[string]) error
func RunInitNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.InitConfiguration, ignorePreflightErrors sets.Set[string], isSecondaryControlPlane bool, downloadCerts bool) error
func RunJoinNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.JoinConfiguration, ignorePreflightErrors sets.Set[string]) error
func RunPullImagesCheck(execer utilsexec.Interface, cfg *kubeadmapi.InitConfiguration, ignorePreflightErrors sets.Set[string]) error
func RunRootCheckOnly(ignorePreflightErrors sets.Set[string]) error
type Checker
    func InitNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.InitConfiguration, ignorePreflightErrors sets.Set[string], isSecondaryControlPlane bool, downloadCerts bool) ([]Checker, error)
    func JoinNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.JoinConfiguration, ignorePreflightErrors sets.Set[string]) ([]Checker, error)
type ContainerRuntimeCheck
    func (crc ContainerRuntimeCheck) Check() (warnings, errorList []error)
    func (ContainerRuntimeCheck) Name() string
type DirAvailableCheck
    func (dac DirAvailableCheck) Check() (warnings, errorList []error)
    func (dac DirAvailableCheck) Name() string
type Error
    func (e *Error) Error() string
    func (e *Error) Preflight() bool
type ExternalEtcdVersionCheck
    func (evc ExternalEtcdVersionCheck) Check() (warnings, errorList []error)
    func (ExternalEtcdVersionCheck) Name() string
type FileAvailableCheck
    func (fac FileAvailableCheck) Check() (warnings, errorList []error)
    func (fac FileAvailableCheck) Name() string
type FileContentCheck
    func (fcc FileContentCheck) Check() (warnings, errorList []error)
    func (fcc FileContentCheck) Name() string
type FileExistingCheck
    func (fac FileExistingCheck) Check() (warnings, errorList []error)
    func (fac FileExistingCheck) Name() string
type FirewalldCheck
    func (fc FirewalldCheck) Check() (warnings, errorList []error)
    func (FirewalldCheck) Name() string
type HTTPProxyCIDRCheck
    func (subnet HTTPProxyCIDRCheck) Check() (warnings, errorList []error)
    func (HTTPProxyCIDRCheck) Name() string
type HTTPProxyCheck
    func (hst HTTPProxyCheck) Check() (warnings, errorList []error)
    func (hst HTTPProxyCheck) Name() string
type HostnameCheck
    func (hc HostnameCheck) Check() (warnings, errorList []error)
    func (HostnameCheck) Name() string
type ImagePullCheck
    func (ipc ImagePullCheck) Check() (warnings, errorList []error)
    func (ImagePullCheck) Name() string
type InPathCheck
    func (ipc InPathCheck) Check() (warnings, errs []error)
    func (ipc InPathCheck) Name() string
type IsPrivilegedUserCheck
    func (ipuc IsPrivilegedUserCheck) Check() (warnings, errorList []error)
    func (IsPrivilegedUserCheck) Name() string
type KubeletVersionCheck
    func (kubever KubeletVersionCheck) Check() (warnings, errorList []error)
    func (KubeletVersionCheck) Name() string
type KubernetesVersionCheck
    func (kubever KubernetesVersionCheck) Check() (warnings, errorList []error)
    func (KubernetesVersionCheck) Name() string
type MemCheck
    func (mc MemCheck) Check() (warnings, errorList []error)
    func (MemCheck) Name() string
type NumCPUCheck
    func (ncc NumCPUCheck) Check() (warnings, errorList []error)
    func (NumCPUCheck) Name() string
type PortOpenCheck
    func (poc PortOpenCheck) Check() (warnings, errorList []error)
    func (poc PortOpenCheck) Name() string
type ServiceCheck
    func (sc ServiceCheck) Check() (warnings, errorList []error)
    func (sc ServiceCheck) Name() string
type SwapCheck
    func (swc SwapCheck) Check() (warnings, errorList []error)
    func (SwapCheck) Name() string
type SystemVerificationCheck
    func (sysver SystemVerificationCheck) Check() (warnings, errorList []error)
    func (SystemVerificationCheck) Name() string

Package files

checks.go checks_linux.go checks_unix.go utils.go

func GetKubeletVersion

func GetKubeletVersion(execer utilsexec.Interface) (*version.Version, error)

GetKubeletVersion is helper function that returns version of kubelet available in $PATH

func RunChecks

func RunChecks(checks []Checker, ww io.Writer, ignorePreflightErrors sets.Set[string]) error

RunChecks runs each check, displays its warnings/errors, and once all are processed will exit if any errors occurred.

func RunInitNodeChecks

func RunInitNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.InitConfiguration, ignorePreflightErrors sets.Set[string], isSecondaryControlPlane bool, downloadCerts bool) error

RunInitNodeChecks executes all individual, applicable to control-plane node checks. The boolean flag 'isSecondaryControlPlane' controls whether we are running checks in a --join-control-plane scenario. The boolean flag 'downloadCerts' controls whether we should skip checks on certificates because we are downloading them. If the flag is set to true we should skip checks already executed by RunJoinNodeChecks.

func RunJoinNodeChecks

func RunJoinNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.JoinConfiguration, ignorePreflightErrors sets.Set[string]) error

RunJoinNodeChecks executes all individual, applicable to node checks.

func RunPullImagesCheck

func RunPullImagesCheck(execer utilsexec.Interface, cfg *kubeadmapi.InitConfiguration, ignorePreflightErrors sets.Set[string]) error

RunPullImagesCheck will pull images kubeadm needs if they are not found on the system

func RunRootCheckOnly

func RunRootCheckOnly(ignorePreflightErrors sets.Set[string]) error

RunRootCheckOnly initializes checks slice of structs and call RunChecks

type Checker

Checker validates the state of the system to ensure kubeadm will be successful as often as possible.

type Checker interface {
    Check() (warnings, errorList []error)
    Name() string
}

func InitNodeChecks

func InitNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.InitConfiguration, ignorePreflightErrors sets.Set[string], isSecondaryControlPlane bool, downloadCerts bool) ([]Checker, error)

InitNodeChecks returns checks specific to "kubeadm init"

func JoinNodeChecks

func JoinNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.JoinConfiguration, ignorePreflightErrors sets.Set[string]) ([]Checker, error)

JoinNodeChecks returns checks specific to "kubeadm join"

type ContainerRuntimeCheck

ContainerRuntimeCheck verifies the container runtime.

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

func (ContainerRuntimeCheck) Check

func (crc ContainerRuntimeCheck) Check() (warnings, errorList []error)

Check validates the container runtime

func (ContainerRuntimeCheck) Name

func (ContainerRuntimeCheck) Name() string

Name returns label for RuntimeCheck.

type DirAvailableCheck

DirAvailableCheck checks if the given directory either does not exist, or is empty.

type DirAvailableCheck struct {
    Path  string
    Label string
}

func (DirAvailableCheck) Check

func (dac DirAvailableCheck) Check() (warnings, errorList []error)

Check validates if a directory does not exist or empty.

func (DirAvailableCheck) Name

func (dac DirAvailableCheck) Name() string

Name returns label for individual DirAvailableChecks. If not known, will return based on path.

type Error

Error defines struct for communicating error messages generated by preflight checks

type Error struct {
    Msg string
}

func (*Error) Error

func (e *Error) Error() string

Error implements the standard error interface

func (*Error) Preflight

func (e *Error) Preflight() bool

Preflight identifies this error as a preflight error

type ExternalEtcdVersionCheck

ExternalEtcdVersionCheck checks if version of external etcd meets the demand of kubeadm

type ExternalEtcdVersionCheck struct {
    Etcd kubeadmapi.Etcd
}

func (ExternalEtcdVersionCheck) Check

func (evc ExternalEtcdVersionCheck) Check() (warnings, errorList []error)

Check validates external etcd version TODO: Use the official etcd Golang client for this instead?

func (ExternalEtcdVersionCheck) Name

func (ExternalEtcdVersionCheck) Name() string

Name will return ExternalEtcdVersion as name for ExternalEtcdVersionCheck

type FileAvailableCheck

FileAvailableCheck checks that the given file does not already exist.

type FileAvailableCheck struct {
    Path  string
    Label string
}

func (FileAvailableCheck) Check

func (fac FileAvailableCheck) Check() (warnings, errorList []error)

Check validates if the given file does not already exist.

func (FileAvailableCheck) Name

func (fac FileAvailableCheck) Name() string

Name returns label for individual FileAvailableChecks. If not known, will return based on path.

type FileContentCheck

FileContentCheck checks that the given file contains the string Content.

type FileContentCheck struct {
    Path    string
    Content []byte
    Label   string
}

func (FileContentCheck) Check

func (fcc FileContentCheck) Check() (warnings, errorList []error)

Check validates if the given file contains the given content.

func (FileContentCheck) Name

func (fcc FileContentCheck) Name() string

Name returns label for individual FileContentChecks. If not known, will return based on path.

type FileExistingCheck

FileExistingCheck checks that the given file does not already exist.

type FileExistingCheck struct {
    Path  string
    Label string
}

func (FileExistingCheck) Check

func (fac FileExistingCheck) Check() (warnings, errorList []error)

Check validates if the given file already exists.

func (FileExistingCheck) Name

func (fac FileExistingCheck) Name() string

Name returns label for individual FileExistingChecks. If not known, will return based on path.

type FirewalldCheck

FirewalldCheck checks if firewalld is enabled or active. If it is, warn the user that there may be problems if no actions are taken.

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

func (FirewalldCheck) Check

func (fc FirewalldCheck) Check() (warnings, errorList []error)

Check validates if the firewall is enabled and active.

func (FirewalldCheck) Name

func (FirewalldCheck) Name() string

Name returns label for FirewalldCheck.

type HTTPProxyCIDRCheck

HTTPProxyCIDRCheck checks if https connection to specific subnet is going to be done directly or over proxy. If proxy detected, it will return warning. Similar to HTTPProxyCheck above, but operates with subnets and uses API machinery transport defaults to simulate kube-apiserver accessing cluster services and pods.

type HTTPProxyCIDRCheck struct {
    Proto string
    CIDR  string
}

func (HTTPProxyCIDRCheck) Check

func (subnet HTTPProxyCIDRCheck) Check() (warnings, errorList []error)

Check validates http connectivity to first IP address in the CIDR. If it is not directly connected and goes via proxy it will produce warning.

func (HTTPProxyCIDRCheck) Name

func (HTTPProxyCIDRCheck) Name() string

Name will return HTTPProxyCIDR as name for HTTPProxyCIDRCheck

type HTTPProxyCheck

HTTPProxyCheck checks if https connection to specific host is going to be done directly or over proxy. If proxy detected, it will return warning.

type HTTPProxyCheck struct {
    Proto string
    Host  string
}

func (HTTPProxyCheck) Check

func (hst HTTPProxyCheck) Check() (warnings, errorList []error)

Check validates http connectivity type, direct or via proxy.

func (HTTPProxyCheck) Name

func (hst HTTPProxyCheck) Name() string

Name returns HTTPProxy as name for HTTPProxyCheck

type HostnameCheck

HostnameCheck checks if hostname match dns subdomain regex. If hostname doesn't match this regex, kubelet will not launch static pods like kube-apiserver/kube-controller-manager and so on.

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

func (HostnameCheck) Check

func (hc HostnameCheck) Check() (warnings, errorList []error)

Check validates if hostname match dns subdomain regex. Check hostname length and format

func (HostnameCheck) Name

func (HostnameCheck) Name() string

Name will return Hostname as name for HostnameCheck

type ImagePullCheck

ImagePullCheck will pull container images used by kubeadm

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

func (ImagePullCheck) Check

func (ipc ImagePullCheck) Check() (warnings, errorList []error)

Check pulls images required by kubeadm. This is a mutating check

func (ImagePullCheck) Name

func (ImagePullCheck) Name() string

Name returns the label for ImagePullCheck

type InPathCheck

InPathCheck checks if the given executable is present in $PATH

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

func (InPathCheck) Check

func (ipc InPathCheck) Check() (warnings, errs []error)

Check validates if the given executable is present in the path.

func (InPathCheck) Name

func (ipc InPathCheck) Name() string

Name returns label for individual InPathCheck. If not known, will return based on path.

type IsPrivilegedUserCheck

IsPrivilegedUserCheck verifies user is privileged (linux - root, windows - Administrator)

type IsPrivilegedUserCheck struct{}

func (IsPrivilegedUserCheck) Check

func (ipuc IsPrivilegedUserCheck) Check() (warnings, errorList []error)

Check validates if an user has elevated (root) privileges.

func (IsPrivilegedUserCheck) Name

func (IsPrivilegedUserCheck) Name() string

Name returns name for IsPrivilegedUserCheck

type KubeletVersionCheck

KubeletVersionCheck validates installed kubelet version

type KubeletVersionCheck struct {
    KubernetesVersion string
    // contains filtered or unexported fields
}

func (KubeletVersionCheck) Check

func (kubever KubeletVersionCheck) Check() (warnings, errorList []error)

Check validates kubelet version. It should be not less than minimal supported version

func (KubeletVersionCheck) Name

func (KubeletVersionCheck) Name() string

Name will return KubeletVersion as name for KubeletVersionCheck

type KubernetesVersionCheck

KubernetesVersionCheck validates Kubernetes and kubeadm versions

type KubernetesVersionCheck struct {
    KubeadmVersion    string
    KubernetesVersion string
}

func (KubernetesVersionCheck) Check

func (kubever KubernetesVersionCheck) Check() (warnings, errorList []error)

Check validates Kubernetes and kubeadm versions

func (KubernetesVersionCheck) Name

func (KubernetesVersionCheck) Name() string

Name will return KubernetesVersion as name for KubernetesVersionCheck

type MemCheck

MemCheck checks if the number of megabytes of memory is not less than required

type MemCheck struct {
    Mem uint64
}

func (MemCheck) Check

func (mc MemCheck) Check() (warnings, errorList []error)

Check number of memory required by kubeadm

func (MemCheck) Name

func (MemCheck) Name() string

Name returns the label for memory

type NumCPUCheck

NumCPUCheck checks if current number of CPUs is not less than required

type NumCPUCheck struct {
    NumCPU int
}

func (NumCPUCheck) Check

func (ncc NumCPUCheck) Check() (warnings, errorList []error)

Check number of CPUs required by kubeadm

func (NumCPUCheck) Name

func (NumCPUCheck) Name() string

Name returns the label for NumCPUCheck

type PortOpenCheck

PortOpenCheck ensures the given port is available for use.

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

func (PortOpenCheck) Check

func (poc PortOpenCheck) Check() (warnings, errorList []error)

Check validates if the particular port is available.

func (PortOpenCheck) Name

func (poc PortOpenCheck) Name() string

Name returns name for PortOpenCheck. If not known, will return "PortXXXX" based on port number

type ServiceCheck

ServiceCheck verifies that the given service is enabled and active. If we do not detect a supported init system however, all checks are skipped and a warning is returned.

type ServiceCheck struct {
    Service       string
    CheckIfActive bool
    Label         string
}

func (ServiceCheck) Check

func (sc ServiceCheck) Check() (warnings, errorList []error)

Check validates if the service is enabled and active.

func (ServiceCheck) Name

func (sc ServiceCheck) Name() string

Name returns label for ServiceCheck. If not provided, will return based on the service parameter

type SwapCheck

SwapCheck warns if swap is enabled

type SwapCheck struct{}

func (SwapCheck) Check

func (swc SwapCheck) Check() (warnings, errorList []error)

Check validates whether swap is enabled or not

func (SwapCheck) Name

func (SwapCheck) Name() string

Name will return Swap as name for SwapCheck

type SystemVerificationCheck

SystemVerificationCheck defines struct used for running the system verification node check in test/e2e_node/system

type SystemVerificationCheck struct{}

func (SystemVerificationCheck) Check

func (sysver SystemVerificationCheck) Check() (warnings, errorList []error)

Check runs all individual checks

func (SystemVerificationCheck) Name

func (SystemVerificationCheck) Name() string

Name will return SystemVerification as name for SystemVerificationCheck