mirror of https://github.com/k3s-io/k3s
kubeadm cleanup: master -> control-plane (cont.2)
parent
3baab4dc35
commit
ae1ec8826a
|
@ -68,7 +68,7 @@ func runPreflight(c workflow.RunData) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("[preflight] Running pre-flight checks")
|
fmt.Println("[preflight] Running pre-flight checks")
|
||||||
if err := preflight.RunInitMasterChecks(utilsexec.New(), data.Cfg(), data.IgnorePreflightErrors()); err != nil {
|
if err := preflight.RunInitNodeChecks(utilsexec.New(), data.Cfg(), data.IgnorePreflightErrors()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ func printFilesIfDryRunning(data waitControlPlaneData) error {
|
||||||
// Print the contents of the upgraded manifests and pretend like they were in /etc/kubernetes/manifests
|
// Print the contents of the upgraded manifests and pretend like they were in /etc/kubernetes/manifests
|
||||||
files := []dryrunutil.FileToPrint{}
|
files := []dryrunutil.FileToPrint{}
|
||||||
// Print static pod manifests
|
// Print static pod manifests
|
||||||
for _, component := range kubeadmconstants.MasterComponents {
|
for _, component := range kubeadmconstants.ControlPlaneComponents {
|
||||||
realPath := kubeadmconstants.GetStaticPodFilepath(component, manifestDir)
|
realPath := kubeadmconstants.GetStaticPodFilepath(component, manifestDir)
|
||||||
outputPath := kubeadmconstants.GetStaticPodFilepath(component, kubeadmconstants.GetStaticPodDirectory())
|
outputPath := kubeadmconstants.GetStaticPodFilepath(component, kubeadmconstants.GetStaticPodDirectory())
|
||||||
files = append(files, dryrunutil.NewFileToPrint(realPath, outputPath))
|
files = append(files, dryrunutil.NewFileToPrint(realPath, outputPath))
|
||||||
|
|
|
@ -125,7 +125,7 @@ func runPreflight(c workflow.RunData) error {
|
||||||
|
|
||||||
// run kubeadm init preflight checks for checking all the prequisites
|
// run kubeadm init preflight checks for checking all the prequisites
|
||||||
fmt.Println("[preflight] Running pre-flight checks before initializing the new control plane instance")
|
fmt.Println("[preflight] Running pre-flight checks before initializing the new control plane instance")
|
||||||
if err := preflight.RunInitMasterChecks(utilsexec.New(), initCfg, j.IgnorePreflightErrors()); err != nil {
|
if err := preflight.RunInitNodeChecks(utilsexec.New(), initCfg, j.IgnorePreflightErrors()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -196,7 +196,7 @@ func runApply(flags *applyFlags) error {
|
||||||
// and block until all DaemonSets are ready; then we know for sure that all control plane images are cached locally
|
// and block until all DaemonSets are ready; then we know for sure that all control plane images are cached locally
|
||||||
klog.V(1).Infof("[upgrade/apply] creating prepuller")
|
klog.V(1).Infof("[upgrade/apply] creating prepuller")
|
||||||
prepuller := upgrade.NewDaemonSetPrepuller(client, waiter, &cfg.ClusterConfiguration)
|
prepuller := upgrade.NewDaemonSetPrepuller(client, waiter, &cfg.ClusterConfiguration)
|
||||||
componentsToPrepull := constants.MasterComponents
|
componentsToPrepull := constants.ControlPlaneComponents
|
||||||
if cfg.Etcd.External == nil && flags.etcdUpgrade {
|
if cfg.Etcd.External == nil && flags.etcdUpgrade {
|
||||||
componentsToPrepull = append(componentsToPrepull, constants.Etcd)
|
componentsToPrepull = append(componentsToPrepull, constants.Etcd)
|
||||||
}
|
}
|
||||||
|
@ -310,7 +310,7 @@ func DryRunStaticPodUpgrade(internalcfg *kubeadmapi.InitConfiguration) error {
|
||||||
|
|
||||||
// Print the contents of the upgraded manifests and pretend like they were in /etc/kubernetes/manifests
|
// Print the contents of the upgraded manifests and pretend like they were in /etc/kubernetes/manifests
|
||||||
files := []dryrunutil.FileToPrint{}
|
files := []dryrunutil.FileToPrint{}
|
||||||
for _, component := range constants.MasterComponents {
|
for _, component := range constants.ControlPlaneComponents {
|
||||||
realPath := constants.GetStaticPodFilepath(component, dryRunManifestDir)
|
realPath := constants.GetStaticPodFilepath(component, dryRunManifestDir)
|
||||||
outputPath := constants.GetStaticPodFilepath(component, constants.GetStaticPodDirectory())
|
outputPath := constants.GetStaticPodFilepath(component, constants.GetStaticPodDirectory())
|
||||||
files = append(files, dryrunutil.NewFileToPrint(realPath, outputPath))
|
files = append(files, dryrunutil.NewFileToPrint(realPath, outputPath))
|
||||||
|
|
|
@ -143,7 +143,7 @@ const (
|
||||||
// the TLS bootstrap to get itself an unique credential
|
// the TLS bootstrap to get itself an unique credential
|
||||||
KubeletBootstrapKubeConfigFileName = "bootstrap-kubelet.conf"
|
KubeletBootstrapKubeConfigFileName = "bootstrap-kubelet.conf"
|
||||||
|
|
||||||
// KubeletKubeConfigFileName defines the file name for the kubeconfig that the master kubelet will use for talking
|
// KubeletKubeConfigFileName defines the file name for the kubeconfig that the control-plane kubelet will use for talking
|
||||||
// to the API server
|
// to the API server
|
||||||
KubeletKubeConfigFileName = "kubelet.conf"
|
KubeletKubeConfigFileName = "kubelet.conf"
|
||||||
// ControllerManagerKubeConfigFileName defines the file name for the controller manager's kubeconfig file
|
// ControllerManagerKubeConfigFileName defines the file name for the controller manager's kubeconfig file
|
||||||
|
@ -157,9 +157,9 @@ const (
|
||||||
ControllerManagerUser = "system:kube-controller-manager"
|
ControllerManagerUser = "system:kube-controller-manager"
|
||||||
// SchedulerUser defines the well-known user the scheduler should be authenticated as
|
// SchedulerUser defines the well-known user the scheduler should be authenticated as
|
||||||
SchedulerUser = "system:kube-scheduler"
|
SchedulerUser = "system:kube-scheduler"
|
||||||
// MastersGroup defines the well-known group for the apiservers. This group is also superuser by default
|
// SystemPrivilegedGroup defines the well-known group for the apiservers. This group is also superuser by default
|
||||||
// (i.e. bound to the cluster-admin ClusterRole)
|
// (i.e. bound to the cluster-admin ClusterRole)
|
||||||
MastersGroup = "system:masters"
|
SystemPrivilegedGroup = "system:masters"
|
||||||
// NodesGroup defines the well-known group for all nodes.
|
// NodesGroup defines the well-known group for all nodes.
|
||||||
NodesGroup = "system:nodes"
|
NodesGroup = "system:nodes"
|
||||||
// NodesUserPrefix defines the user name prefix as requested by the Node authorizer.
|
// NodesUserPrefix defines the user name prefix as requested by the Node authorizer.
|
||||||
|
@ -171,9 +171,9 @@ const (
|
||||||
|
|
||||||
// APICallRetryInterval defines how long kubeadm should wait before retrying a failed API operation
|
// APICallRetryInterval defines how long kubeadm should wait before retrying a failed API operation
|
||||||
APICallRetryInterval = 500 * time.Millisecond
|
APICallRetryInterval = 500 * time.Millisecond
|
||||||
// DiscoveryRetryInterval specifies how long kubeadm should wait before retrying to connect to the master when doing discovery
|
// DiscoveryRetryInterval specifies how long kubeadm should wait before retrying to connect to the control-plane when doing discovery
|
||||||
DiscoveryRetryInterval = 5 * time.Second
|
DiscoveryRetryInterval = 5 * time.Second
|
||||||
// PatchNodeTimeout specifies how long kubeadm should wait for applying the label and taint on the master before timing out
|
// PatchNodeTimeout specifies how long kubeadm should wait for applying the label and taint on the control-plane before timing out
|
||||||
PatchNodeTimeout = 2 * time.Minute
|
PatchNodeTimeout = 2 * time.Minute
|
||||||
// UpdateNodeTimeout specifies how long kubeadm should wait for updating node with the initial remote configuration of kubelet before timing out
|
// UpdateNodeTimeout specifies how long kubeadm should wait for updating node with the initial remote configuration of kubelet before timing out
|
||||||
UpdateNodeTimeout = 2 * time.Minute
|
UpdateNodeTimeout = 2 * time.Minute
|
||||||
|
@ -198,7 +198,7 @@ const (
|
||||||
// CertificateKeySize specifies the size of the key used to encrypt certificates on uploadcerts phase
|
// CertificateKeySize specifies the size of the key used to encrypt certificates on uploadcerts phase
|
||||||
CertificateKeySize = 32
|
CertificateKeySize = 32
|
||||||
|
|
||||||
// LabelNodeRoleMaster specifies that a node is a master
|
// LabelNodeRoleMaster specifies that a node is a control-plane
|
||||||
// This is a duplicate definition of the constant in pkg/controller/service/service_controller.go
|
// This is a duplicate definition of the constant in pkg/controller/service/service_controller.go
|
||||||
LabelNodeRoleMaster = "node-role.kubernetes.io/master"
|
LabelNodeRoleMaster = "node-role.kubernetes.io/master"
|
||||||
|
|
||||||
|
@ -357,22 +357,22 @@ const (
|
||||||
// DefaultAPIServerBindAddress is the default bind address for the API Server
|
// DefaultAPIServerBindAddress is the default bind address for the API Server
|
||||||
DefaultAPIServerBindAddress = "0.0.0.0"
|
DefaultAPIServerBindAddress = "0.0.0.0"
|
||||||
|
|
||||||
// MasterNumCPU is the number of CPUs required on master
|
// ControlPlaneNumCPU is the number of CPUs required on control-plane
|
||||||
MasterNumCPU = 2
|
ControlPlaneNumCPU = 2
|
||||||
|
|
||||||
// KubeadmCertsSecret specifies in what Secret in the kube-system namespace the certificates should be stored
|
// KubeadmCertsSecret specifies in what Secret in the kube-system namespace the certificates should be stored
|
||||||
KubeadmCertsSecret = "kubeadm-certs"
|
KubeadmCertsSecret = "kubeadm-certs"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// MasterTaint is the taint to apply on the PodSpec for being able to run that Pod on the master
|
// ControlPlaneTaint is the taint to apply on the PodSpec for being able to run that Pod on the control-plane
|
||||||
MasterTaint = v1.Taint{
|
ControlPlaneTaint = v1.Taint{
|
||||||
Key: LabelNodeRoleMaster,
|
Key: LabelNodeRoleMaster,
|
||||||
Effect: v1.TaintEffectNoSchedule,
|
Effect: v1.TaintEffectNoSchedule,
|
||||||
}
|
}
|
||||||
|
|
||||||
// MasterToleration is the toleration to apply on the PodSpec for being able to run that Pod on the master
|
// ControlPlaneToleration is the toleration to apply on the PodSpec for being able to run that Pod on the control-plane
|
||||||
MasterToleration = v1.Toleration{
|
ControlPlaneToleration = v1.Toleration{
|
||||||
Key: LabelNodeRoleMaster,
|
Key: LabelNodeRoleMaster,
|
||||||
Effect: v1.TaintEffectNoSchedule,
|
Effect: v1.TaintEffectNoSchedule,
|
||||||
}
|
}
|
||||||
|
@ -383,8 +383,8 @@ var (
|
||||||
// DefaultTokenGroups specifies the default groups that this token will authenticate as when used for authentication
|
// DefaultTokenGroups specifies the default groups that this token will authenticate as when used for authentication
|
||||||
DefaultTokenGroups = []string{NodeBootstrapTokenAuthGroup}
|
DefaultTokenGroups = []string{NodeBootstrapTokenAuthGroup}
|
||||||
|
|
||||||
// MasterComponents defines the master component names
|
// ControlPlaneComponents defines the control-plane component names
|
||||||
MasterComponents = []string{KubeAPIServer, KubeControllerManager, KubeScheduler}
|
ControlPlaneComponents = []string{KubeAPIServer, KubeControllerManager, KubeScheduler}
|
||||||
|
|
||||||
// MinimumControlPlaneVersion specifies the minimum control plane version kubeadm can deploy
|
// MinimumControlPlaneVersion specifies the minimum control plane version kubeadm can deploy
|
||||||
MinimumControlPlaneVersion = version.MustParseSemantic("v1.12.0")
|
MinimumControlPlaneVersion = version.MustParseSemantic("v1.12.0")
|
||||||
|
|
|
@ -265,7 +265,7 @@ var (
|
||||||
CAName: "ca",
|
CAName: "ca",
|
||||||
config: certutil.Config{
|
config: certutil.Config{
|
||||||
CommonName: kubeadmconstants.APIServerKubeletClientCertCommonName,
|
CommonName: kubeadmconstants.APIServerKubeletClientCertCommonName,
|
||||||
Organization: []string{kubeadmconstants.MastersGroup},
|
Organization: []string{kubeadmconstants.SystemPrivilegedGroup},
|
||||||
Usages: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth},
|
Usages: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -341,7 +341,7 @@ var (
|
||||||
CAName: "etcd-ca",
|
CAName: "etcd-ca",
|
||||||
config: certutil.Config{
|
config: certutil.Config{
|
||||||
CommonName: kubeadmconstants.EtcdHealthcheckClientCertCommonName,
|
CommonName: kubeadmconstants.EtcdHealthcheckClientCertCommonName,
|
||||||
Organization: []string{kubeadmconstants.MastersGroup},
|
Organization: []string{kubeadmconstants.SystemPrivilegedGroup},
|
||||||
Usages: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth},
|
Usages: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -353,7 +353,7 @@ var (
|
||||||
CAName: "etcd-ca",
|
CAName: "etcd-ca",
|
||||||
config: certutil.Config{
|
config: certutil.Config{
|
||||||
CommonName: kubeadmconstants.APIServerEtcdClientCertCommonName,
|
CommonName: kubeadmconstants.APIServerEtcdClientCertCommonName,
|
||||||
Organization: []string{kubeadmconstants.MastersGroup},
|
Organization: []string{kubeadmconstants.SystemPrivilegedGroup},
|
||||||
Usages: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth},
|
Usages: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,7 @@ func getKubeConfigSpecs(cfg *kubeadmapi.InitConfiguration) (map[string]*kubeConf
|
||||||
ClientName: "kubernetes-admin",
|
ClientName: "kubernetes-admin",
|
||||||
ClientCertAuth: &clientCertAuth{
|
ClientCertAuth: &clientCertAuth{
|
||||||
CAKey: caKey,
|
CAKey: caKey,
|
||||||
Organizations: []string{kubeadmconstants.MastersGroup},
|
Organizations: []string{kubeadmconstants.SystemPrivilegedGroup},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
kubeadmconstants.KubeletKubeConfigFileName: {
|
kubeadmconstants.KubeletKubeConfigFileName: {
|
||||||
|
|
|
@ -118,7 +118,7 @@ func TestGetKubeConfigSpecs(t *testing.T) {
|
||||||
{
|
{
|
||||||
kubeConfigFile: kubeadmconstants.AdminKubeConfigFileName,
|
kubeConfigFile: kubeadmconstants.AdminKubeConfigFileName,
|
||||||
clientName: "kubernetes-admin",
|
clientName: "kubernetes-admin",
|
||||||
organizations: []string{kubeadmconstants.MastersGroup},
|
organizations: []string{kubeadmconstants.SystemPrivilegedGroup},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kubeConfigFile: kubeadmconstants.KubeletKubeConfigFileName,
|
kubeConfigFile: kubeadmconstants.KubeletKubeConfigFileName,
|
||||||
|
|
|
@ -49,7 +49,7 @@ func TestMarkControlPlane(t *testing.T) {
|
||||||
"control-plane label and taint missing",
|
"control-plane label and taint missing",
|
||||||
"",
|
"",
|
||||||
nil,
|
nil,
|
||||||
[]v1.Taint{kubeadmconstants.MasterTaint},
|
[]v1.Taint{kubeadmconstants.ControlPlaneTaint},
|
||||||
"{\"metadata\":{\"labels\":{\"node-role.kubernetes.io/master\":\"\"}},\"spec\":{\"taints\":[{\"effect\":\"NoSchedule\",\"key\":\"node-role.kubernetes.io/master\"}]}}",
|
"{\"metadata\":{\"labels\":{\"node-role.kubernetes.io/master\":\"\"}},\"spec\":{\"taints\":[{\"effect\":\"NoSchedule\",\"key\":\"node-role.kubernetes.io/master\"}]}}",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -62,22 +62,22 @@ func TestMarkControlPlane(t *testing.T) {
|
||||||
{
|
{
|
||||||
"control-plane label missing",
|
"control-plane label missing",
|
||||||
"",
|
"",
|
||||||
[]v1.Taint{kubeadmconstants.MasterTaint},
|
[]v1.Taint{kubeadmconstants.ControlPlaneTaint},
|
||||||
[]v1.Taint{kubeadmconstants.MasterTaint},
|
[]v1.Taint{kubeadmconstants.ControlPlaneTaint},
|
||||||
"{\"metadata\":{\"labels\":{\"node-role.kubernetes.io/master\":\"\"}}}",
|
"{\"metadata\":{\"labels\":{\"node-role.kubernetes.io/master\":\"\"}}}",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"control-plane taint missing",
|
"control-plane taint missing",
|
||||||
kubeadmconstants.LabelNodeRoleMaster,
|
kubeadmconstants.LabelNodeRoleMaster,
|
||||||
nil,
|
nil,
|
||||||
[]v1.Taint{kubeadmconstants.MasterTaint},
|
[]v1.Taint{kubeadmconstants.ControlPlaneTaint},
|
||||||
"{\"spec\":{\"taints\":[{\"effect\":\"NoSchedule\",\"key\":\"node-role.kubernetes.io/master\"}]}}",
|
"{\"spec\":{\"taints\":[{\"effect\":\"NoSchedule\",\"key\":\"node-role.kubernetes.io/master\"}]}}",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"nothing missing",
|
"nothing missing",
|
||||||
kubeadmconstants.LabelNodeRoleMaster,
|
kubeadmconstants.LabelNodeRoleMaster,
|
||||||
[]v1.Taint{kubeadmconstants.MasterTaint},
|
[]v1.Taint{kubeadmconstants.ControlPlaneTaint},
|
||||||
[]v1.Taint{kubeadmconstants.MasterTaint},
|
[]v1.Taint{kubeadmconstants.ControlPlaneTaint},
|
||||||
"{}",
|
"{}",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -101,7 +101,7 @@ func TestMarkControlPlane(t *testing.T) {
|
||||||
Effect: v1.TaintEffectNoSchedule,
|
Effect: v1.TaintEffectNoSchedule,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[]v1.Taint{kubeadmconstants.MasterTaint},
|
[]v1.Taint{kubeadmconstants.ControlPlaneTaint},
|
||||||
"{\"spec\":{\"taints\":[{\"effect\":\"NoSchedule\",\"key\":\"node-role.kubernetes.io/master\"},{\"effect\":\"NoSchedule\",\"key\":\"node.cloudprovider.kubernetes.io/uninitialized\"}]}}",
|
"{\"spec\":{\"taints\":[{\"effect\":\"NoSchedule\",\"key\":\"node-role.kubernetes.io/master\"},{\"effect\":\"NoSchedule\",\"key\":\"node.cloudprovider.kubernetes.io/uninitialized\"}]}}",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,11 +95,11 @@ func addNodeSelectorToPodSpec(podSpec *v1.PodSpec) {
|
||||||
// setMasterTolerationOnPodSpec makes the Pod tolerate the master taint
|
// setMasterTolerationOnPodSpec makes the Pod tolerate the master taint
|
||||||
func setMasterTolerationOnPodSpec(podSpec *v1.PodSpec) {
|
func setMasterTolerationOnPodSpec(podSpec *v1.PodSpec) {
|
||||||
if podSpec.Tolerations == nil {
|
if podSpec.Tolerations == nil {
|
||||||
podSpec.Tolerations = []v1.Toleration{kubeadmconstants.MasterToleration}
|
podSpec.Tolerations = []v1.Toleration{kubeadmconstants.ControlPlaneToleration}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
podSpec.Tolerations = append(podSpec.Tolerations, kubeadmconstants.MasterToleration)
|
podSpec.Tolerations = append(podSpec.Tolerations, kubeadmconstants.ControlPlaneToleration)
|
||||||
}
|
}
|
||||||
|
|
||||||
// setHostIPOnPodSpec sets the environment variable HOST_IP using downward API
|
// setHostIPOnPodSpec sets the environment variable HOST_IP using downward API
|
||||||
|
|
|
@ -69,7 +69,7 @@ func TestMutatePodSpec(t *testing.T) {
|
||||||
kubeadmconstants.LabelNodeRoleMaster: "",
|
kubeadmconstants.LabelNodeRoleMaster: "",
|
||||||
},
|
},
|
||||||
Tolerations: []v1.Toleration{
|
Tolerations: []v1.Toleration{
|
||||||
kubeadmconstants.MasterToleration,
|
kubeadmconstants.ControlPlaneToleration,
|
||||||
},
|
},
|
||||||
DNSPolicy: v1.DNSClusterFirstWithHostNet,
|
DNSPolicy: v1.DNSClusterFirstWithHostNet,
|
||||||
},
|
},
|
||||||
|
@ -83,7 +83,7 @@ func TestMutatePodSpec(t *testing.T) {
|
||||||
kubeadmconstants.LabelNodeRoleMaster: "",
|
kubeadmconstants.LabelNodeRoleMaster: "",
|
||||||
},
|
},
|
||||||
Tolerations: []v1.Toleration{
|
Tolerations: []v1.Toleration{
|
||||||
kubeadmconstants.MasterToleration,
|
kubeadmconstants.ControlPlaneToleration,
|
||||||
},
|
},
|
||||||
DNSPolicy: v1.DNSClusterFirstWithHostNet,
|
DNSPolicy: v1.DNSClusterFirstWithHostNet,
|
||||||
},
|
},
|
||||||
|
@ -97,7 +97,7 @@ func TestMutatePodSpec(t *testing.T) {
|
||||||
kubeadmconstants.LabelNodeRoleMaster: "",
|
kubeadmconstants.LabelNodeRoleMaster: "",
|
||||||
},
|
},
|
||||||
Tolerations: []v1.Toleration{
|
Tolerations: []v1.Toleration{
|
||||||
kubeadmconstants.MasterToleration,
|
kubeadmconstants.ControlPlaneToleration,
|
||||||
},
|
},
|
||||||
DNSPolicy: v1.DNSClusterFirstWithHostNet,
|
DNSPolicy: v1.DNSClusterFirstWithHostNet,
|
||||||
},
|
},
|
||||||
|
@ -168,7 +168,7 @@ func TestSetMasterTolerationOnPodSpec(t *testing.T) {
|
||||||
podSpec: &v1.PodSpec{},
|
podSpec: &v1.PodSpec{},
|
||||||
expected: v1.PodSpec{
|
expected: v1.PodSpec{
|
||||||
Tolerations: []v1.Toleration{
|
Tolerations: []v1.Toleration{
|
||||||
kubeadmconstants.MasterToleration,
|
kubeadmconstants.ControlPlaneToleration,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -182,7 +182,7 @@ func TestSetMasterTolerationOnPodSpec(t *testing.T) {
|
||||||
expected: v1.PodSpec{
|
expected: v1.PodSpec{
|
||||||
Tolerations: []v1.Toleration{
|
Tolerations: []v1.Toleration{
|
||||||
{Key: "foo", Value: "bar"},
|
{Key: "foo", Value: "bar"},
|
||||||
kubeadmconstants.MasterToleration,
|
kubeadmconstants.ControlPlaneToleration,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -75,7 +75,7 @@ func CreateSelfHostedControlPlane(manifestsDir, kubeConfigDir string, cfg *kubea
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, componentName := range kubeadmconstants.MasterComponents {
|
for _, componentName := range kubeadmconstants.ControlPlaneComponents {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
manifestPath := kubeadmconstants.GetStaticPodFilepath(componentName, manifestsDir)
|
manifestPath := kubeadmconstants.GetStaticPodFilepath(componentName, manifestsDir)
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ func masterNodesReady(client clientset.Interface) error {
|
||||||
// staticPodManifestHealth makes sure the required static pods are presents
|
// staticPodManifestHealth makes sure the required static pods are presents
|
||||||
func staticPodManifestHealth(_ clientset.Interface) error {
|
func staticPodManifestHealth(_ clientset.Interface) error {
|
||||||
nonExistentManifests := []string{}
|
nonExistentManifests := []string{}
|
||||||
for _, component := range constants.MasterComponents {
|
for _, component := range constants.ControlPlaneComponents {
|
||||||
manifestFile := constants.GetStaticPodFilepath(component, constants.GetStaticPodDirectory())
|
manifestFile := constants.GetStaticPodFilepath(component, constants.GetStaticPodDirectory())
|
||||||
if _, err := os.Stat(manifestFile); os.IsNotExist(err) {
|
if _, err := os.Stat(manifestFile); os.IsNotExist(err) {
|
||||||
nonExistentManifests = append(nonExistentManifests, manifestFile)
|
nonExistentManifests = append(nonExistentManifests, manifestFile)
|
||||||
|
@ -152,7 +152,7 @@ func IsControlPlaneSelfHosted(client clientset.Interface) bool {
|
||||||
// getNotReadyDaemonSets gets the amount of Ready control plane DaemonSets
|
// getNotReadyDaemonSets gets the amount of Ready control plane DaemonSets
|
||||||
func getNotReadyDaemonSets(client clientset.Interface) ([]error, error) {
|
func getNotReadyDaemonSets(client clientset.Interface) ([]error, error) {
|
||||||
notReadyDaemonSets := []error{}
|
notReadyDaemonSets := []error{}
|
||||||
for _, component := range constants.MasterComponents {
|
for _, component := range constants.ControlPlaneComponents {
|
||||||
dsName := constants.AddSelfHostedPrefix(component)
|
dsName := constants.AddSelfHostedPrefix(component)
|
||||||
ds, err := client.AppsV1().DaemonSets(metav1.NamespaceSystem).Get(dsName, metav1.GetOptions{})
|
ds, err := client.AppsV1().DaemonSets(metav1.NamespaceSystem).Get(dsName, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -42,7 +42,7 @@ type Prepuller interface {
|
||||||
DeleteFunc(string) error
|
DeleteFunc(string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// DaemonSetPrepuller makes sure the control plane images are available on all masters
|
// DaemonSetPrepuller makes sure the control-plane images are available on all masters
|
||||||
type DaemonSetPrepuller struct {
|
type DaemonSetPrepuller struct {
|
||||||
client clientset.Interface
|
client clientset.Interface
|
||||||
cfg *kubeadmapi.ClusterConfiguration
|
cfg *kubeadmapi.ClusterConfiguration
|
||||||
|
@ -181,7 +181,7 @@ func buildPrePullDaemonSet(component, image string) *apps.DaemonSet {
|
||||||
NodeSelector: map[string]string{
|
NodeSelector: map[string]string{
|
||||||
constants.LabelNodeRoleMaster: "",
|
constants.LabelNodeRoleMaster: "",
|
||||||
},
|
},
|
||||||
Tolerations: []v1.Toleration{constants.MasterToleration},
|
Tolerations: []v1.Toleration{constants.ControlPlaneToleration},
|
||||||
TerminationGracePeriodSeconds: &gracePeriodSecs,
|
TerminationGracePeriodSeconds: &gracePeriodSecs,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -141,7 +141,7 @@ func TestPrepullImagesInParallel(t *testing.T) {
|
||||||
|
|
||||||
for _, rt := range tests {
|
for _, rt := range tests {
|
||||||
t.Run(rt.name, func(t *testing.T) {
|
t.Run(rt.name, func(t *testing.T) {
|
||||||
actualErr := PrepullImagesInParallel(rt.p, rt.timeout, append(constants.MasterComponents, constants.Etcd))
|
actualErr := PrepullImagesInParallel(rt.p, rt.timeout, append(constants.ControlPlaneComponents, constants.Etcd))
|
||||||
if (actualErr != nil) != rt.expectedErr {
|
if (actualErr != nil) != rt.expectedErr {
|
||||||
t.Errorf(
|
t.Errorf(
|
||||||
"failed TestPrepullImagesInParallel\n\texpected error: %t\n\tgot: %t",
|
"failed TestPrepullImagesInParallel\n\texpected error: %t\n\tgot: %t",
|
||||||
|
|
|
@ -436,7 +436,7 @@ func StaticPodControlPlane(client clientset.Interface, waiter apiclient.Waiter,
|
||||||
return errors.Wrap(err, "error creating init static pod manifest files")
|
return errors.Wrap(err, "error creating init static pod manifest files")
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, component := range constants.MasterComponents {
|
for _, component := range constants.ControlPlaneComponents {
|
||||||
if err = upgradeComponent(component, waiter, pathMgr, cfg, beforePodHashMap[component], recoverManifests); err != nil {
|
if err = upgradeComponent(component, waiter, pathMgr, cfg, beforePodHashMap[component], recoverManifests); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -871,8 +871,8 @@ func (ncc NumCPUCheck) Check() (warnings, errorList []error) {
|
||||||
return warnings, errorList
|
return warnings, errorList
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunInitMasterChecks executes all individual, applicable to Master node checks.
|
// RunInitNodeChecks executes all individual, applicable to control-plane node checks.
|
||||||
func RunInitMasterChecks(execer utilsexec.Interface, cfg *kubeadmapi.InitConfiguration, ignorePreflightErrors sets.String) error {
|
func RunInitNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.InitConfiguration, ignorePreflightErrors sets.String) error {
|
||||||
// First, check if we're root separately from the other preflight checks and fail fast
|
// First, check if we're root separately from the other preflight checks and fail fast
|
||||||
if err := RunRootCheckOnly(ignorePreflightErrors); err != nil {
|
if err := RunRootCheckOnly(ignorePreflightErrors); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -880,7 +880,7 @@ func RunInitMasterChecks(execer utilsexec.Interface, cfg *kubeadmapi.InitConfigu
|
||||||
|
|
||||||
manifestsDir := filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.ManifestsSubDirName)
|
manifestsDir := filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.ManifestsSubDirName)
|
||||||
checks := []Checker{
|
checks := []Checker{
|
||||||
NumCPUCheck{NumCPU: kubeadmconstants.MasterNumCPU},
|
NumCPUCheck{NumCPU: kubeadmconstants.ControlPlaneNumCPU},
|
||||||
KubernetesVersionCheck{KubernetesVersion: cfg.KubernetesVersion, KubeadmVersion: kubeadmversion.Get().GitVersion},
|
KubernetesVersionCheck{KubernetesVersion: cfg.KubernetesVersion, KubeadmVersion: kubeadmversion.Get().GitVersion},
|
||||||
FirewalldCheck{ports: []int{int(cfg.LocalAPIEndpoint.BindPort), 10250}},
|
FirewalldCheck{ports: []int{int(cfg.LocalAPIEndpoint.BindPort), 10250}},
|
||||||
PortOpenCheck{port: int(cfg.LocalAPIEndpoint.BindPort)},
|
PortOpenCheck{port: int(cfg.LocalAPIEndpoint.BindPort)},
|
||||||
|
|
|
@ -184,7 +184,7 @@ func (pfct preflightCheckTest) Check() (warning, errorList []error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRunInitMasterChecks(t *testing.T) {
|
func TestRunInitNodeChecks(t *testing.T) {
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
name string
|
name string
|
||||||
cfg *kubeadmapi.InitConfiguration
|
cfg *kubeadmapi.InitConfiguration
|
||||||
|
@ -231,11 +231,11 @@ func TestRunInitMasterChecks(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, rt := range tests {
|
for _, rt := range tests {
|
||||||
// TODO: Make RunInitMasterChecks accept a ClusterConfiguration object instead of InitConfiguration
|
// TODO: Make RunInitNodeChecks accept a ClusterConfiguration object instead of InitConfiguration
|
||||||
actual := RunInitMasterChecks(exec.New(), rt.cfg, sets.NewString())
|
actual := RunInitNodeChecks(exec.New(), rt.cfg, sets.NewString())
|
||||||
if (actual == nil) != rt.expected {
|
if (actual == nil) != rt.expected {
|
||||||
t.Errorf(
|
t.Errorf(
|
||||||
"failed RunInitMasterChecks:\n\texpected: %t\n\t actual: %t\n\t error: %v",
|
"failed RunInitNodeChecks:\n\texpected: %t\n\t actual: %t\n\t error: %v",
|
||||||
rt.expected,
|
rt.expected,
|
||||||
(actual == nil),
|
(actual == nil),
|
||||||
actual,
|
actual,
|
||||||
|
|
|
@ -187,7 +187,7 @@ func (w *KubeWaiter) WaitForStaticPodControlPlaneHashes(nodeName string) (map[st
|
||||||
componentHash := ""
|
componentHash := ""
|
||||||
var err error
|
var err error
|
||||||
mirrorPodHashes := map[string]string{}
|
mirrorPodHashes := map[string]string{}
|
||||||
for _, component := range constants.MasterComponents {
|
for _, component := range constants.ControlPlaneComponents {
|
||||||
err = wait.PollImmediate(constants.APICallRetryInterval, w.timeout, func() (bool, error) {
|
err = wait.PollImmediate(constants.APICallRetryInterval, w.timeout, func() (bool, error) {
|
||||||
componentHash, err = getStaticPodSingleHash(w.client, nodeName, component)
|
componentHash, err = getStaticPodSingleHash(w.client, nodeName, component)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -59,7 +59,6 @@ func FetchInitConfigurationFromCluster(client clientset.Interface, w io.Writer,
|
||||||
|
|
||||||
// getInitConfigurationFromCluster is separate only for testing purposes, don't call it directly, use FetchInitConfigurationFromCluster instead
|
// getInitConfigurationFromCluster is separate only for testing purposes, don't call it directly, use FetchInitConfigurationFromCluster instead
|
||||||
func getInitConfigurationFromCluster(kubeconfigDir string, client clientset.Interface, newControlPlane bool) (*kubeadmapi.InitConfiguration, error) {
|
func getInitConfigurationFromCluster(kubeconfigDir string, client clientset.Interface, newControlPlane bool) (*kubeadmapi.InitConfiguration, error) {
|
||||||
// TODO: This code should support reading the MasterConfiguration key as well for backwards-compat
|
|
||||||
// Also, the config map really should be KubeadmConfigConfigMap...
|
// Also, the config map really should be KubeadmConfigConfigMap...
|
||||||
configMap, err := client.CoreV1().ConfigMaps(metav1.NamespaceSystem).Get(constants.KubeadmConfigConfigMap, metav1.GetOptions{})
|
configMap, err := client.CoreV1().ConfigMaps(metav1.NamespaceSystem).Get(constants.KubeadmConfigConfigMap, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -268,7 +268,7 @@ func TestGetNodeRegistration(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Spec: v1.NodeSpec{
|
Spec: v1.NodeSpec{
|
||||||
Taints: []v1.Taint{kubeadmconstants.MasterTaint},
|
Taints: []v1.Taint{kubeadmconstants.ControlPlaneTaint},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -551,7 +551,7 @@ func TestGetInitConfigurationFromCluster(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Spec: v1.NodeSpec{
|
Spec: v1.NodeSpec{
|
||||||
Taints: []v1.Taint{kubeadmconstants.MasterTaint},
|
Taints: []v1.Taint{kubeadmconstants.ControlPlaneTaint},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -611,7 +611,7 @@ func TestGetInitConfigurationFromCluster(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Spec: v1.NodeSpec{
|
Spec: v1.NodeSpec{
|
||||||
Taints: []v1.Taint{kubeadmconstants.MasterTaint},
|
Taints: []v1.Taint{kubeadmconstants.ControlPlaneTaint},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -85,16 +85,16 @@ func SetBootstrapTokensDynamicDefaults(cfg *[]kubeadmapi.BootstrapToken) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetNodeRegistrationDynamicDefaults checks and sets configuration values for the NodeRegistration object
|
// SetNodeRegistrationDynamicDefaults checks and sets configuration values for the NodeRegistration object
|
||||||
func SetNodeRegistrationDynamicDefaults(cfg *kubeadmapi.NodeRegistrationOptions, masterTaint bool) error {
|
func SetNodeRegistrationDynamicDefaults(cfg *kubeadmapi.NodeRegistrationOptions, ControlPlaneTaint bool) error {
|
||||||
var err error
|
var err error
|
||||||
cfg.Name, err = nodeutil.GetHostname(cfg.Name)
|
cfg.Name, err = nodeutil.GetHostname(cfg.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only if the slice is nil, we should append the master taint. This allows the user to specify an empty slice for no default master taint
|
// Only if the slice is nil, we should append the control-plane taint. This allows the user to specify an empty slice for no default control-plane taint
|
||||||
if masterTaint && cfg.Taints == nil {
|
if ControlPlaneTaint && cfg.Taints == nil {
|
||||||
cfg.Taints = []v1.Taint{kubeadmconstants.MasterTaint}
|
cfg.Taints = []v1.Taint{kubeadmconstants.ControlPlaneTaint}
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg.CRISocket == "" {
|
if cfg.CRISocket == "" {
|
||||||
|
|
Loading…
Reference in New Issue