upgrade

package
v1.9.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2017 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
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 = 1
)

Variables

This section is empty.

Functions

func ActiveDNSAddon added in v1.9.0

func ActiveDNSAddon(featureGates map[string]bool) string

ActiveDNSAddon returns the version of CoreDNS or kube-dns

func BuildUpgradedDaemonSetsFromConfig

func BuildUpgradedDaemonSetsFromConfig(cfg *kubeadmapi.MasterConfiguration, k8sVersion *version.Version) map[string]*apps.DaemonSet

BuildUpgradedDaemonSetsFromConfig takes a config object and the current version and returns the DaemonSet objects to post to the master

func CheckClusterHealth

func CheckClusterHealth(client clientset.Interface, ignoreChecksErrors sets.String) error

CheckClusterHealth makes sure: - the API /healthz endpoint is healthy - all master Nodes are Ready - (if self-hosted) that there are DaemonSets with at least one Pod for all control plane components - (if static pod-hosted) that all required Static Pod manifests exist on disk

func FetchConfiguration

func FetchConfiguration(client clientset.Interface, w io.Writer, cfgPath string) (*kubeadmapiext.MasterConfiguration, error)

FetchConfiguration fetches configuration required for upgrading your cluster from a file (which has precedence) or a ConfigMap in the cluster

func IsControlPlaneSelfHosted

func IsControlPlaneSelfHosted(client clientset.Interface) bool

IsControlPlaneSelfHosted returns whether the control plane is self hosted or not

func PerformPostUpgradeTasks

func PerformPostUpgradeTasks(client clientset.Interface, cfg *kubeadmapi.MasterConfiguration, newK8sVer *version.Version, dryRun bool) error

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

func PrepullImagesInParallel

func PrepullImagesInParallel(kubePrepuller Prepuller, timeout time.Duration) error

PrepullImagesInParallel creates DaemonSets synchronously but waits in parallel for the images to pull

func SelfHostedControlPlane

func SelfHostedControlPlane(client clientset.Interface, waiter apiclient.Waiter, cfg *kubeadmapi.MasterConfiguration, k8sVersion *version.Version) error

SelfHostedControlPlane upgrades a self-hosted control plane It works as follows: - The client gets the currently running DaemonSets and their associated Pods used for self-hosting the control plane - A temporary DaemonSet for the component in question is created; but nearly identical to the DaemonSet for the self-hosted component running right now

  • Why use this temporary DaemonSet? Because, the RollingUpdate strategy for upgrading DaemonSets first kills the old Pod, and then adds the new one
  • This doesn't work for self-hosted upgrades, as if you remove the only API server for instance you have in the cluster, the cluster essentially goes down
  • So instead, a nearly identical copy of the pre-upgrade DaemonSet is created and applied to the cluster. In the beginning, this duplicate DS is just idle

- kubeadm waits for the temporary DaemonSet's Pod to become Running - kubeadm updates the real, self-hosted component. This will result in the pre-upgrade component Pod being removed from the cluster

  • Luckily, the temporary, backup DaemonSet now kicks in and takes over and acts as the control plane. It recognizes that a new Pod should be created,
  • as the "real" DaemonSet is being updated.

- kubeadm waits for the pre-upgrade Pod to become deleted. It now takes advantage of the backup/temporary component - kubeadm waits for the new, upgraded DaemonSet to become Running. - Now that the new, upgraded DaemonSet is Running, we can delete the backup/temporary DaemonSet - Lastly, make sure the API /healthz endpoint still is reachable

TL;DR; This is what the flow looks like in pseudo-code: for [kube-apiserver, kube-controller-manager, kube-scheduler], do:

  1. Self-Hosted component v1 Running -> Duplicate the DaemonSet manifest
  2. Self-Hosted component v1 Running (active). Backup component v1 Running (passive) -> Upgrade the Self-Hosted component v1 to v2. -> Self-Hosted component v1 is Deleted from the cluster
  3. Backup component v1 Running becomes active and completes the upgrade by creating the Self-Hosted component v2 Pod (passive) -> Wait for Self-Hosted component v2 to become Running
  4. Backup component v1 Running (active). Self-Hosted component v2 Running (passive) -> Backup component v1 is Deleted
  5. Wait for Self-Hosted component v2 Running to become active
  6. Repeat for all control plane components

func StaticPodControlPlane

func StaticPodControlPlane(waiter apiclient.Waiter, pathMgr StaticPodPathManager, cfg *kubeadmapi.MasterConfiguration, etcdUpgrade bool) error

StaticPodControlPlane upgrades a static pod-hosted control plane

Types

type ClusterState

type ClusterState struct {
	// KubeVersion describes the version of the Kubernetes API Server, Controller Manager, Scheduler and Proxy.
	KubeVersion string
	// DNSVersion describes the version of the kube-dns images used and manifest version
	DNSVersion string
	// KubeadmVersion describes the version of the kubeadm CLI
	KubeadmVersion string
	// KubeletVersions is a map with a version number linked to the amount of kubelets running that version in the cluster
	KubeletVersions map[string]uint16
	// EtcdVersion represents the version of etcd used in the cluster
	EtcdVersion string
}

ClusterState describes the state of certain versions for a cluster

type DaemonSetPrepuller

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

DaemonSetPrepuller makes sure the control plane images are availble on all masters

func NewDaemonSetPrepuller

func NewDaemonSetPrepuller(client clientset.Interface, waiter apiclient.Waiter, cfg *kubeadmapi.MasterConfiguration) *DaemonSetPrepuller

NewDaemonSetPrepuller creates a new instance of the DaemonSetPrepuller struct

func (*DaemonSetPrepuller) CreateFunc

func (d *DaemonSetPrepuller) CreateFunc(component string) error

CreateFunc creates a DaemonSet for making the image available on every relevant node

func (*DaemonSetPrepuller) DeleteFunc

func (d *DaemonSetPrepuller) DeleteFunc(component string) error

DeleteFunc deletes the DaemonSet used for making the image available on every relevant node

func (*DaemonSetPrepuller) WaitFunc

func (d *DaemonSetPrepuller) WaitFunc(component string)

WaitFunc waits for all Pods in the specified DaemonSet to be in the Running state

type KubeStaticPodPathManager

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

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

func (*KubeStaticPodPathManager) BackupEtcdDir added in v1.9.0

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) MoveFile

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

MoveFile should move a file from oldPath to newPath

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

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

KubeVersionGetter handles the version-fetching mechanism from external sources

func (*KubeVersionGetter) ClusterVersion

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

ClusterVersion gets API server version

func (*KubeVersionGetter) KubeadmVersion

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

KubeadmVersion gets kubeadm version

func (*KubeVersionGetter) KubeletVersions

func (g *KubeVersionGetter) KubeletVersions() (map[string]uint16, 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 Prepuller

type Prepuller interface {
	CreateFunc(string) error
	WaitFunc(string)
	DeleteFunc(string) error
}

Prepuller defines an interface for performing a prepull operation in a create-wait-delete fashion in parallel

type StaticPodPathManager

type StaticPodPathManager interface {
	// MoveFile should move a file from oldPath to newPath
	MoveFile(oldPath, newPath string) error
	// 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
}

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

func NewKubeStaticPodPathManager

func NewKubeStaticPodPathManager(realDir, tempDir, backupDir, backupEtcdDir string) StaticPodPathManager

NewKubeStaticPodPathManager creates a new instance of KubeStaticPodPathManager

func NewKubeStaticPodPathManagerUsingTempDirs

func NewKubeStaticPodPathManagerUsingTempDirs(realManifestDir string) (StaticPodPathManager, error)

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

type Upgrade

type Upgrade struct {
	Description string
	Before      ClusterState
	After       ClusterState
}

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

func GetAvailableUpgrades

func GetAvailableUpgrades(versionGetterImpl VersionGetter, experimentalUpgradesAllowed, rcUpgradesAllowed bool, cluster util.EtcdCluster, featureGates map[string]bool) ([]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

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 number that describes how many kubelets there are for that version
	KubeletVersions() (map[string]uint16, error)
}

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

func NewKubeVersionGetter

func NewKubeVersionGetter(client clientset.Interface, writer io.Writer) VersionGetter

NewKubeVersionGetter returns a new instance of KubeVersionGetter

type VersionSkewPolicyErrors

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

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

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

Jump to

Keyboard shortcuts

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