...

Package upgrade

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

Overview ▾

Index ▾

Constants
func CheckClusterHealth(client clientset.Interface, cfg *kubeadmapi.ClusterConfiguration, ignoreChecksErrors sets.Set[string], printer output.Printer) error
func DryRunStaticPodUpgrade(patchesDir string, internalcfg *kubeadmapi.InitConfiguration) error
func GetEtcdImageTagFromStaticPod(manifestDir string) (string, error)
func GetKubeletDir(dryRun bool) (string, error)
func PerformAddonsUpgrade(client clientset.Interface, cfg *kubeadmapi.InitConfiguration, out io.Writer) error
func PerformPostUpgradeTasks(client clientset.Interface, cfg *kubeadmapi.InitConfiguration, patchesDir string, dryRun bool, out io.Writer) error
func PerformStaticPodUpgrade(client clientset.Interface, waiter apiclient.Waiter, internalcfg *kubeadmapi.InitConfiguration, etcdUpgrade, renewCerts bool, patchesDir string) error
func RunCoreDNSMigrationCheck(client clientset.Interface, ignorePreflightErrors sets.Set[string]) error
func StaticPodControlPlane(client clientset.Interface, waiter apiclient.Waiter, pathMgr StaticPodPathManager, cfg *kubeadmapi.InitConfiguration, etcdUpgrade, renewCerts bool, oldEtcdClient, newEtcdClient etcdutil.ClusterInterrogator) error
func WriteKubeletConfigFiles(cfg *kubeadmapi.InitConfiguration, patchesDir string, dryRun bool, out io.Writer) error
type ClusterState
type CoreDNSCheck
    func (c CoreDNSCheck) Check() (warnings, errors []error)
    func (c CoreDNSCheck) Name() string
type KubeStaticPodPathManager
    func (spm *KubeStaticPodPathManager) BackupEtcdDir() string
    func (spm *KubeStaticPodPathManager) BackupManifestDir() string
    func (spm *KubeStaticPodPathManager) BackupManifestPath(component string) string
    func (spm *KubeStaticPodPathManager) CleanupDirs() error
    func (spm *KubeStaticPodPathManager) KubernetesDir() string
    func (spm *KubeStaticPodPathManager) MoveFile(oldPath, newPath string) error
    func (spm *KubeStaticPodPathManager) PatchesDir() string
    func (spm *KubeStaticPodPathManager) RealManifestDir() string
    func (spm *KubeStaticPodPathManager) RealManifestPath(component string) string
    func (spm *KubeStaticPodPathManager) TempManifestDir() string
    func (spm *KubeStaticPodPathManager) TempManifestPath(component string) string
type KubeVersionGetter
    func (g *KubeVersionGetter) ClusterVersion() (string, *versionutil.Version, error)
    func (g *KubeVersionGetter) ComponentVersions(name string) (map[string][]string, error)
    func (g *KubeVersionGetter) KubeadmVersion() (string, *versionutil.Version, error)
    func (g *KubeVersionGetter) KubeletVersions() (map[string][]string, error)
    func (g *KubeVersionGetter) VersionFromCILabel(ciVersionLabel, description string) (string, *versionutil.Version, error)
type OfflineVersionGetter
    func (o *OfflineVersionGetter) VersionFromCILabel(ciVersionLabel, description string) (string, *versionutil.Version, error)
type StaticPodPathManager
    func GetPathManagerForUpgrade(kubernetesDir, patchesDir string, internalcfg *kubeadmapi.InitConfiguration, etcdUpgrade bool) (StaticPodPathManager, error)
    func NewKubeStaticPodPathManager(kubernetesDir, patchesDir, tempDir, backupDir, backupEtcdDir string, keepManifestDir, keepEtcdDir bool) StaticPodPathManager
    func NewKubeStaticPodPathManagerUsingTempDirs(kubernetesDir, patchesDir string, saveManifestsDir, saveEtcdDir bool) (StaticPodPathManager, error)
type Upgrade
    func GetAvailableUpgrades(versionGetterImpl VersionGetter, experimentalUpgradesAllowed, rcUpgradesAllowed bool, client clientset.Interface, printer output.Printer) ([]Upgrade, error)
    func (u *Upgrade) CanUpgradeKubelets() bool
type VersionGetter
    func NewKubeVersionGetter(client clientset.Interface) VersionGetter
    func NewOfflineVersionGetter(versionGetter VersionGetter, version string) VersionGetter
type VersionSkewPolicyErrors
    func EnforceVersionPolicies(versionGetter VersionGetter, newK8sVersionStr string, newK8sVersion *version.Version, allowExperimentalUpgrades, allowRCUpgrades bool) *VersionSkewPolicyErrors

Package files

compute.go health.go policy.go postupgrade.go preflight.go staticpods.go versiongetter.go

Constants

const (
    // MaximumAllowedMinorVersionUpgradeSkew describes how many minor versions kubeadm can upgrade the control plane version in one go
    MaximumAllowedMinorVersionUpgradeSkew = 1

    // MaximumAllowedMinorVersionDowngradeSkew describes how many minor versions kubeadm can upgrade the control plane version in one go
    MaximumAllowedMinorVersionDowngradeSkew = 1

    // MaximumAllowedMinorVersionKubeletSkew describes how many minor versions the control plane version and the kubelet can skew in a kubeadm cluster
    MaximumAllowedMinorVersionKubeletSkew = 3
)

func CheckClusterHealth

func CheckClusterHealth(client clientset.Interface, cfg *kubeadmapi.ClusterConfiguration, ignoreChecksErrors sets.Set[string], printer output.Printer) error

CheckClusterHealth makes sure: - the cluster can accept a workload - all control-plane Nodes are Ready - (if static pod-hosted) that all required Static Pod manifests exist on disk

func DryRunStaticPodUpgrade

func DryRunStaticPodUpgrade(patchesDir string, internalcfg *kubeadmapi.InitConfiguration) error

DryRunStaticPodUpgrade fakes an upgrade of the control plane

func GetEtcdImageTagFromStaticPod

func GetEtcdImageTagFromStaticPod(manifestDir string) (string, error)

GetEtcdImageTagFromStaticPod returns the image tag of the local etcd static pod

func GetKubeletDir

func GetKubeletDir(dryRun bool) (string, error)

GetKubeletDir gets the kubelet directory based on whether the user is dry-running this command or not.

func PerformAddonsUpgrade

func PerformAddonsUpgrade(client clientset.Interface, cfg *kubeadmapi.InitConfiguration, out io.Writer) error

PerformAddonsUpgrade performs the upgrade of the coredns and kube-proxy addons. When UpgradeAddonsBeforeControlPlane feature gate is enabled, the addons will be upgraded immediately. When UpgradeAddonsBeforeControlPlane feature gate is disabled, the addons will only get updated after all the control plane instances have been upgraded.

func PerformPostUpgradeTasks

func PerformPostUpgradeTasks(client clientset.Interface, cfg *kubeadmapi.InitConfiguration, patchesDir string, dryRun bool, out io.Writer) error

PerformPostUpgradeTasks runs nearly the same functions as 'kubeadm init' would do Note that the mark-control-plane phase is left out, not needed, and no token is created as that doesn't belong to the upgrade

func PerformStaticPodUpgrade

func PerformStaticPodUpgrade(client clientset.Interface, waiter apiclient.Waiter, internalcfg *kubeadmapi.InitConfiguration, etcdUpgrade, renewCerts bool, patchesDir string) error

PerformStaticPodUpgrade performs the upgrade of the control plane components for a static pod hosted cluster

func RunCoreDNSMigrationCheck

func RunCoreDNSMigrationCheck(client clientset.Interface, ignorePreflightErrors sets.Set[string]) error

RunCoreDNSMigrationCheck initializes checks related to CoreDNS migration.

func StaticPodControlPlane

func StaticPodControlPlane(client clientset.Interface, waiter apiclient.Waiter, pathMgr StaticPodPathManager, cfg *kubeadmapi.InitConfiguration, etcdUpgrade, renewCerts bool, oldEtcdClient, newEtcdClient etcdutil.ClusterInterrogator) error

StaticPodControlPlane upgrades a static pod-hosted control plane

func WriteKubeletConfigFiles

func WriteKubeletConfigFiles(cfg *kubeadmapi.InitConfiguration, patchesDir string, dryRun bool, out io.Writer) error

WriteKubeletConfigFiles writes the kubelet config file to disk, but first creates a backup of any existing one.

type ClusterState

ClusterState describes the state of certain versions for a cluster during an upgrade

type ClusterState struct {
    // KubeVersion describes the version of latest Kubernetes API Server in the cluster.
    KubeVersion string
    // DNSVersion describes the version of the DNS add-on.
    DNSVersion string
    // KubeadmVersion describes the version of the kubeadm CLI
    KubeadmVersion string
    // EtcdVersion represents the version of etcd used in the cluster
    EtcdVersion string

    // The following maps describe the versions of the different components in the cluster.
    // The key is the version string and the value is a list of nodes that have that version.
    KubeAPIServerVersions         map[string][]string
    KubeControllerManagerVersions map[string][]string
    KubeSchedulerVersions         map[string][]string
    EtcdVersions                  map[string][]string
    KubeletVersions               map[string][]string
}

type CoreDNSCheck

CoreDNSCheck validates installed kubelet version

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

func (CoreDNSCheck) Check

func (c CoreDNSCheck) Check() (warnings, errors []error)

Check is part of the preflight.Checker interface

func (CoreDNSCheck) Name

func (c CoreDNSCheck) Name() string

Name is part of the preflight.Checker interface

type KubeStaticPodPathManager

KubeStaticPodPathManager is a real implementation of StaticPodPathManager that is used when upgrading a static pod cluster

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

func (*KubeStaticPodPathManager) BackupEtcdDir

func (spm *KubeStaticPodPathManager) BackupEtcdDir() string

BackupEtcdDir should point to the backup directory used for backuping manifests during the transition

func (*KubeStaticPodPathManager) BackupManifestDir

func (spm *KubeStaticPodPathManager) BackupManifestDir() string

BackupManifestDir should point to the backup directory used for backuping manifests during the transition

func (*KubeStaticPodPathManager) BackupManifestPath

func (spm *KubeStaticPodPathManager) BackupManifestPath(component string) string

BackupManifestPath gets the file path for the component in the backup directory used for backuping manifests during the transition

func (*KubeStaticPodPathManager) CleanupDirs

func (spm *KubeStaticPodPathManager) CleanupDirs() error

CleanupDirs cleans up all temporary directories except those the user has requested to keep around

func (*KubeStaticPodPathManager) KubernetesDir

func (spm *KubeStaticPodPathManager) KubernetesDir() string

KubernetesDir should point to the directory Kubernetes owns for storing various configuration files

func (*KubeStaticPodPathManager) MoveFile

func (spm *KubeStaticPodPathManager) MoveFile(oldPath, newPath string) error

MoveFile should move a file from oldPath to newPath

func (*KubeStaticPodPathManager) PatchesDir

func (spm *KubeStaticPodPathManager) PatchesDir() string

PatchesDir should point to the folder where patches for components are stored

func (*KubeStaticPodPathManager) RealManifestDir

func (spm *KubeStaticPodPathManager) RealManifestDir() string

RealManifestDir should point to the static pod manifest directory used by the kubelet

func (*KubeStaticPodPathManager) RealManifestPath

func (spm *KubeStaticPodPathManager) RealManifestPath(component string) string

RealManifestPath gets the file path for the component in the "real" static pod manifest directory used by the kubelet

func (*KubeStaticPodPathManager) TempManifestDir

func (spm *KubeStaticPodPathManager) TempManifestDir() string

TempManifestDir should point to the temporary directory created for generating new manifests for the upgrade

func (*KubeStaticPodPathManager) TempManifestPath

func (spm *KubeStaticPodPathManager) TempManifestPath(component string) string

TempManifestPath gets the file path for the component in the temporary directory created for generating new manifests for the upgrade

type KubeVersionGetter

KubeVersionGetter handles the version-fetching mechanism from external sources

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

func (*KubeVersionGetter) ClusterVersion

func (g *KubeVersionGetter) ClusterVersion() (string, *versionutil.Version, error)

ClusterVersion gets API server version

func (*KubeVersionGetter) ComponentVersions

func (g *KubeVersionGetter) ComponentVersions(name string) (map[string][]string, error)

ComponentVersions gets the versions of the control-plane components in the cluster. The name parameter is the name of the component to get the versions for. The function returns a map with the version as the key and a list of node names as the value.

func (*KubeVersionGetter) KubeadmVersion

func (g *KubeVersionGetter) KubeadmVersion() (string, *versionutil.Version, error)

KubeadmVersion gets kubeadm version

func (*KubeVersionGetter) KubeletVersions

func (g *KubeVersionGetter) KubeletVersions() (map[string][]string, error)

KubeletVersions gets the versions of the kubelets in the cluster.

func (*KubeVersionGetter) VersionFromCILabel

func (g *KubeVersionGetter) VersionFromCILabel(ciVersionLabel, description string) (string, *versionutil.Version, error)

VersionFromCILabel resolves a version label like "latest" or "stable" to an actual version using the public Kubernetes CI uploads

type OfflineVersionGetter

OfflineVersionGetter will use the version provided or

type OfflineVersionGetter struct {
    VersionGetter
    // contains filtered or unexported fields
}

func (*OfflineVersionGetter) VersionFromCILabel

func (o *OfflineVersionGetter) VersionFromCILabel(ciVersionLabel, description string) (string, *versionutil.Version, error)

VersionFromCILabel will return the version that was passed into the struct

type StaticPodPathManager

StaticPodPathManager is responsible for tracking the directories used in the static pod upgrade transition

type StaticPodPathManager interface {
    // MoveFile should move a file from oldPath to newPath
    MoveFile(oldPath, newPath string) error
    // KubernetesDir is the directory Kubernetes owns for storing various configuration files
    KubernetesDir() string
    // PatchesDir should point to the folder where patches for components are stored
    PatchesDir() string
    // RealManifestPath gets the file path for the component in the "real" static pod manifest directory used by the kubelet
    RealManifestPath(component string) string
    // RealManifestDir should point to the static pod manifest directory used by the kubelet
    RealManifestDir() string
    // TempManifestPath gets the file path for the component in the temporary directory created for generating new manifests for the upgrade
    TempManifestPath(component string) string
    // TempManifestDir should point to the temporary directory created for generating new manifests for the upgrade
    TempManifestDir() string
    // BackupManifestPath gets the file path for the component in the backup directory used for backuping manifests during the transition
    BackupManifestPath(component string) string
    // BackupManifestDir should point to the backup directory used for backuping manifests during the transition
    BackupManifestDir() string
    // BackupEtcdDir should point to the backup directory used for backuping manifests during the transition
    BackupEtcdDir() string
    // CleanupDirs cleans up all temporary directories
    CleanupDirs() error
}

func GetPathManagerForUpgrade

func GetPathManagerForUpgrade(kubernetesDir, patchesDir string, internalcfg *kubeadmapi.InitConfiguration, etcdUpgrade bool) (StaticPodPathManager, error)

GetPathManagerForUpgrade returns a path manager properly configured for the given InitConfiguration.

func NewKubeStaticPodPathManager

func NewKubeStaticPodPathManager(kubernetesDir, patchesDir, tempDir, backupDir, backupEtcdDir string, keepManifestDir, keepEtcdDir bool) StaticPodPathManager

NewKubeStaticPodPathManager creates a new instance of KubeStaticPodPathManager

func NewKubeStaticPodPathManagerUsingTempDirs

func NewKubeStaticPodPathManagerUsingTempDirs(kubernetesDir, patchesDir string, saveManifestsDir, saveEtcdDir bool) (StaticPodPathManager, error)

NewKubeStaticPodPathManagerUsingTempDirs creates a new instance of KubeStaticPodPathManager with temporary directories backing it

type Upgrade

Upgrade defines an upgrade possibility to upgrade from a current version to a new one

type Upgrade struct {
    Description string
    Before      ClusterState
    After       ClusterState
}

func GetAvailableUpgrades

func GetAvailableUpgrades(versionGetterImpl VersionGetter, experimentalUpgradesAllowed, rcUpgradesAllowed bool, client clientset.Interface, printer output.Printer) ([]Upgrade, error)

GetAvailableUpgrades fetches all versions from the specified VersionGetter and computes which kinds of upgrades can be performed

func (*Upgrade) CanUpgradeKubelets

func (u *Upgrade) CanUpgradeKubelets() bool

CanUpgradeKubelets returns whether an upgrade of any kubelet in the cluster is possible

type VersionGetter

VersionGetter defines an interface for fetching different versions. Easy to implement a fake variant of this interface for unit testing

type VersionGetter interface {
    // ClusterVersion should return the version of the cluster i.e. the API Server version
    ClusterVersion() (string, *versionutil.Version, error)
    // KubeadmVersion should return the version of the kubeadm CLI
    KubeadmVersion() (string, *versionutil.Version, error)
    // VersionFromCILabel should resolve CI labels like `latest`, `stable`, `stable-1.8`, etc. to real versions
    VersionFromCILabel(string, string) (string, *versionutil.Version, error)
    // KubeletVersions should return a map with a version and a list of node names that describes how many kubelets there are for that version
    KubeletVersions() (map[string][]string, error)
    // ComponentVersions should return a map with a version and a list of node names that describes how many a given control-plane components there are for that version
    ComponentVersions(string) (map[string][]string, error)
}

func NewKubeVersionGetter

func NewKubeVersionGetter(client clientset.Interface) VersionGetter

NewKubeVersionGetter returns a new instance of KubeVersionGetter

func NewOfflineVersionGetter

func NewOfflineVersionGetter(versionGetter VersionGetter, version string) VersionGetter

NewOfflineVersionGetter wraps a VersionGetter and skips online communication if default information is supplied. Version can be "" and the behavior will be identical to the versionGetter passed in.

type VersionSkewPolicyErrors

VersionSkewPolicyErrors describes version skew errors that might be seen during the validation process in EnforceVersionPolicies

type VersionSkewPolicyErrors struct {
    Mandatory []error
    Skippable []error
}

func EnforceVersionPolicies

func EnforceVersionPolicies(versionGetter VersionGetter, newK8sVersionStr string, newK8sVersion *version.Version, allowExperimentalUpgrades, allowRCUpgrades bool) *VersionSkewPolicyErrors

EnforceVersionPolicies enforces that the proposed new version is compatible with all the different version skew policies