From 6536c0b3018d3fa3378b2bd25d41efda2248ee84 Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Fri, 25 Nov 2022 16:44:12 -0800 Subject: [PATCH] v1alpha3: use new terminology for kubelet config --- nodeup/pkg/model/kubelet.go | 6 +++--- pkg/apis/kops/cluster.go | 10 +++++----- pkg/apis/kops/v1alpha2/cluster.go | 8 ++++---- .../kops/v1alpha2/zz_generated.conversion.go | 12 +++++------ .../kops/v1alpha2/zz_generated.deepcopy.go | 4 ++-- pkg/apis/kops/v1alpha3/cluster.go | 10 +++++----- .../kops/v1alpha3/zz_generated.conversion.go | 12 +++++------ .../kops/v1alpha3/zz_generated.deepcopy.go | 4 ++-- pkg/apis/kops/validation/legacy.go | 20 +++++++++---------- pkg/apis/kops/validation/validation.go | 8 ++++---- pkg/apis/kops/zz_generated.deepcopy.go | 4 ++-- pkg/model/bootstrapscript.go | 2 +- pkg/model/bootstrapscript_test.go | 2 +- pkg/model/components/kubelet.go | 16 +++++++-------- pkg/nodelabels/builder.go | 2 +- pkg/nodelabels/builder_test.go | 4 ++-- .../integration/conversion/aws/v1alpha2.yaml | 2 ++ .../integration/conversion/aws/v1alpha3.yaml | 2 ++ .../fi/cloudup/populate_cluster_spec_test.go | 12 +++++------ .../fi/cloudup/populate_instancegroup_spec.go | 6 +++--- .../populate_instancegroup_spec_test.go | 2 +- upup/pkg/fi/cloudup/spec_builder.go | 10 +++++----- 22 files changed, 81 insertions(+), 77 deletions(-) diff --git a/nodeup/pkg/model/kubelet.go b/nodeup/pkg/model/kubelet.go index 46500c25dc..03dd5c8785 100644 --- a/nodeup/pkg/model/kubelet.go +++ b/nodeup/pkg/model/kubelet.go @@ -132,7 +132,7 @@ func (b *KubeletBuilder) Build(c *fi.ModelBuilderContext) error { if b.HasAPIServer || !b.UseBootstrapTokens() { var kubeconfig fi.Resource if b.HasAPIServer { - kubeconfig, err = b.buildMasterKubeletKubeconfig(c) + kubeconfig, err = b.buildControlPlaneKubeletKubeconfig(c) } else { kubeconfig, err = b.BuildBootstrapKubeconfig("kubelet", c) } @@ -608,8 +608,8 @@ func (b *KubeletBuilder) buildKubeletConfigSpec() (*kops.KubeletConfigSpec, erro return &c, nil } -// buildMasterKubeletKubeconfig builds a kubeconfig for the master kubelet, self-signing the kubelet cert -func (b *KubeletBuilder) buildMasterKubeletKubeconfig(c *fi.ModelBuilderContext) (fi.Resource, error) { +// buildControlPlaneKubeletKubeconfig builds a kubeconfig for the master kubelet, self-signing the kubelet cert +func (b *KubeletBuilder) buildControlPlaneKubeletKubeconfig(c *fi.ModelBuilderContext) (fi.Resource, error) { nodeName, err := b.NodeName() if err != nil { return nil, fmt.Errorf("error getting NodeName: %v", err) diff --git a/pkg/apis/kops/cluster.go b/pkg/apis/kops/cluster.go index 37effa3ddf..b72a3d02c6 100644 --- a/pkg/apis/kops/cluster.go +++ b/pkg/apis/kops/cluster.go @@ -150,12 +150,12 @@ type ClusterSpec struct { // Kubelet is the kubelet configuration for nodes not belonging to the control plane. // It can be overridden by the kubelet configuration specified in the instance group. Kubelet *KubeletConfigSpec `json:"kubelet,omitempty"` - // MasterKubelet is the kubelet configuration for nodes belonging to the control plane + // ControlPlaneKubelet is the kubelet configuration for nodes belonging to the control plane // It can be overridden by the kubelet configuration specified in the instance group. - MasterKubelet *KubeletConfigSpec `json:"masterKubelet,omitempty"` - CloudConfig *CloudConfiguration `json:"cloudConfig,omitempty"` - ExternalDNS *ExternalDNSConfig `json:"externalDNS,omitempty"` - NTP *NTPConfig `json:"ntp,omitempty"` + ControlPlaneKubelet *KubeletConfigSpec `json:"controlPlaneKubelet,omitempty"` + CloudConfig *CloudConfiguration `json:"cloudConfig,omitempty"` + ExternalDNS *ExternalDNSConfig `json:"externalDNS,omitempty"` + NTP *NTPConfig `json:"ntp,omitempty"` // NodeTerminationHandler determines the node termination handler configuration. NodeTerminationHandler *NodeTerminationHandlerConfig `json:"nodeTerminationHandler,omitempty"` diff --git a/pkg/apis/kops/v1alpha2/cluster.go b/pkg/apis/kops/v1alpha2/cluster.go index fafefa8afd..de22e68ca4 100644 --- a/pkg/apis/kops/v1alpha2/cluster.go +++ b/pkg/apis/kops/v1alpha2/cluster.go @@ -166,10 +166,10 @@ type ClusterSpec struct { Kubelet *KubeletConfigSpec `json:"kubelet,omitempty"` // MasterKubelet is the kubelet configuration for nodes belonging to the control plane // It can be overridden by the kubelet configuration specified in the instance group. - MasterKubelet *KubeletConfigSpec `json:"masterKubelet,omitempty"` - CloudConfig *CloudConfiguration `json:"cloudConfig,omitempty"` - ExternalDNS *ExternalDNSConfig `json:"externalDns,omitempty"` - NTP *NTPConfig `json:"ntp,omitempty"` + ControlPlaneKubelet *KubeletConfigSpec `json:"masterKubelet,omitempty"` + CloudConfig *CloudConfiguration `json:"cloudConfig,omitempty"` + ExternalDNS *ExternalDNSConfig `json:"externalDns,omitempty"` + NTP *NTPConfig `json:"ntp,omitempty"` // NodeTerminationHandler determines the cluster autoscaler configuration. NodeTerminationHandler *NodeTerminationHandlerConfig `json:"nodeTerminationHandler,omitempty"` diff --git a/pkg/apis/kops/v1alpha2/zz_generated.conversion.go b/pkg/apis/kops/v1alpha2/zz_generated.conversion.go index 9ac446b1c5..da96823292 100644 --- a/pkg/apis/kops/v1alpha2/zz_generated.conversion.go +++ b/pkg/apis/kops/v1alpha2/zz_generated.conversion.go @@ -2603,14 +2603,14 @@ func autoConvert_v1alpha2_ClusterSpec_To_kops_ClusterSpec(in *ClusterSpec, out * } else { out.Kubelet = nil } - if in.MasterKubelet != nil { - in, out := &in.MasterKubelet, &out.MasterKubelet + if in.ControlPlaneKubelet != nil { + in, out := &in.ControlPlaneKubelet, &out.ControlPlaneKubelet *out = new(kops.KubeletConfigSpec) if err := Convert_v1alpha2_KubeletConfigSpec_To_kops_KubeletConfigSpec(*in, *out, s); err != nil { return err } } else { - out.MasterKubelet = nil + out.ControlPlaneKubelet = nil } if in.CloudConfig != nil { in, out := &in.CloudConfig, &out.CloudConfig @@ -3018,14 +3018,14 @@ func autoConvert_kops_ClusterSpec_To_v1alpha2_ClusterSpec(in *kops.ClusterSpec, } else { out.Kubelet = nil } - if in.MasterKubelet != nil { - in, out := &in.MasterKubelet, &out.MasterKubelet + if in.ControlPlaneKubelet != nil { + in, out := &in.ControlPlaneKubelet, &out.ControlPlaneKubelet *out = new(KubeletConfigSpec) if err := Convert_kops_KubeletConfigSpec_To_v1alpha2_KubeletConfigSpec(*in, *out, s); err != nil { return err } } else { - out.MasterKubelet = nil + out.ControlPlaneKubelet = nil } if in.CloudConfig != nil { in, out := &in.CloudConfig, &out.CloudConfig diff --git a/pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go b/pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go index cd08bd78a3..4b00e5216a 100644 --- a/pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go +++ b/pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go @@ -1211,8 +1211,8 @@ func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) { *out = new(KubeletConfigSpec) (*in).DeepCopyInto(*out) } - if in.MasterKubelet != nil { - in, out := &in.MasterKubelet, &out.MasterKubelet + if in.ControlPlaneKubelet != nil { + in, out := &in.ControlPlaneKubelet, &out.ControlPlaneKubelet *out = new(KubeletConfigSpec) (*in).DeepCopyInto(*out) } diff --git a/pkg/apis/kops/v1alpha3/cluster.go b/pkg/apis/kops/v1alpha3/cluster.go index 0f1d7b348a..61ff395773 100644 --- a/pkg/apis/kops/v1alpha3/cluster.go +++ b/pkg/apis/kops/v1alpha3/cluster.go @@ -147,12 +147,12 @@ type ClusterSpec struct { // Kubelet is the kubelet configuration for nodes not belonging to the control plane. // It can be overridden by the kubelet configuration specified in the instance group. Kubelet *KubeletConfigSpec `json:"kubelet,omitempty"` - // MasterKubelet is the kubelet configuration for nodes belonging to the control plane + // ControlPlaneKubelet is the kubelet configuration for nodes belonging to the control plane // It can be overridden by the kubelet configuration specified in the instance group. - MasterKubelet *KubeletConfigSpec `json:"masterKubelet,omitempty"` - CloudConfig *CloudConfiguration `json:"cloudConfig,omitempty"` - ExternalDNS *ExternalDNSConfig `json:"externalDNS,omitempty"` - NTP *NTPConfig `json:"ntp,omitempty"` + ControlPlaneKubelet *KubeletConfigSpec `json:"controlPlaneKubelet,omitempty"` + CloudConfig *CloudConfiguration `json:"cloudConfig,omitempty"` + ExternalDNS *ExternalDNSConfig `json:"externalDNS,omitempty"` + NTP *NTPConfig `json:"ntp,omitempty"` // NodeTerminationHandler determines the cluster autoscaler configuration. NodeTerminationHandler *NodeTerminationHandlerConfig `json:"nodeTerminationHandler,omitempty"` diff --git a/pkg/apis/kops/v1alpha3/zz_generated.conversion.go b/pkg/apis/kops/v1alpha3/zz_generated.conversion.go index a51f2237db..1bc4e1bf86 100644 --- a/pkg/apis/kops/v1alpha3/zz_generated.conversion.go +++ b/pkg/apis/kops/v1alpha3/zz_generated.conversion.go @@ -2708,14 +2708,14 @@ func autoConvert_v1alpha3_ClusterSpec_To_kops_ClusterSpec(in *ClusterSpec, out * } else { out.Kubelet = nil } - if in.MasterKubelet != nil { - in, out := &in.MasterKubelet, &out.MasterKubelet + if in.ControlPlaneKubelet != nil { + in, out := &in.ControlPlaneKubelet, &out.ControlPlaneKubelet *out = new(kops.KubeletConfigSpec) if err := Convert_v1alpha3_KubeletConfigSpec_To_kops_KubeletConfigSpec(*in, *out, s); err != nil { return err } } else { - out.MasterKubelet = nil + out.ControlPlaneKubelet = nil } if in.CloudConfig != nil { in, out := &in.CloudConfig, &out.CloudConfig @@ -3121,14 +3121,14 @@ func autoConvert_kops_ClusterSpec_To_v1alpha3_ClusterSpec(in *kops.ClusterSpec, } else { out.Kubelet = nil } - if in.MasterKubelet != nil { - in, out := &in.MasterKubelet, &out.MasterKubelet + if in.ControlPlaneKubelet != nil { + in, out := &in.ControlPlaneKubelet, &out.ControlPlaneKubelet *out = new(KubeletConfigSpec) if err := Convert_kops_KubeletConfigSpec_To_v1alpha3_KubeletConfigSpec(*in, *out, s); err != nil { return err } } else { - out.MasterKubelet = nil + out.ControlPlaneKubelet = nil } if in.CloudConfig != nil { in, out := &in.CloudConfig, &out.CloudConfig diff --git a/pkg/apis/kops/v1alpha3/zz_generated.deepcopy.go b/pkg/apis/kops/v1alpha3/zz_generated.deepcopy.go index d4f56e92e6..faff1d42d5 100644 --- a/pkg/apis/kops/v1alpha3/zz_generated.deepcopy.go +++ b/pkg/apis/kops/v1alpha3/zz_generated.deepcopy.go @@ -1159,8 +1159,8 @@ func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) { *out = new(KubeletConfigSpec) (*in).DeepCopyInto(*out) } - if in.MasterKubelet != nil { - in, out := &in.MasterKubelet, &out.MasterKubelet + if in.ControlPlaneKubelet != nil { + in, out := &in.ControlPlaneKubelet, &out.ControlPlaneKubelet *out = new(KubeletConfigSpec) (*in).DeepCopyInto(*out) } diff --git a/pkg/apis/kops/validation/legacy.go b/pkg/apis/kops/validation/legacy.go index e4a6b92b35..211717a601 100644 --- a/pkg/apis/kops/validation/legacy.go +++ b/pkg/apis/kops/validation/legacy.go @@ -118,8 +118,8 @@ func ValidateCluster(c *kops.Cluster, strict bool) field.ErrorList { if strict && c.Spec.Kubelet == nil { allErrs = append(allErrs, field.Required(fieldSpec.Child("kubelet"), "kubelet not configured")) } - if strict && c.Spec.MasterKubelet == nil { - allErrs = append(allErrs, field.Required(fieldSpec.Child("masterKubelet"), "masterKubelet not configured")) + if strict && c.Spec.ControlPlaneKubelet == nil { + allErrs = append(allErrs, field.Required(fieldSpec.Child("controlPlaneKubelet"), "controlPlaneKubelet not configured")) } if strict && c.Spec.KubeControllerManager == nil { allErrs = append(allErrs, field.Required(fieldSpec.Child("kubeControllerManager"), "kubeControllerManager not configured")) @@ -215,9 +215,9 @@ func ValidateCluster(c *kops.Cluster, strict bool) field.ErrorList { allErrs = append(allErrs, field.Forbidden(fieldSpec.Child("kubelet", "nonMasqueradeCIDR"), "kubelet nonMasqueradeCIDR did not match cluster nonMasqueradeCIDR")) } } - if fi.ValueOf(c.Spec.MasterKubelet.NonMasqueradeCIDR) != nonMasqueradeCIDRString { - if strict || c.Spec.MasterKubelet.NonMasqueradeCIDR != nil { - allErrs = append(allErrs, field.Forbidden(fieldSpec.Child("masterKubelet", "nonMasqueradeCIDR"), "masterKubelet nonMasqueradeCIDR did not match cluster nonMasqueradeCIDR")) + if fi.ValueOf(c.Spec.ControlPlaneKubelet.NonMasqueradeCIDR) != nonMasqueradeCIDRString { + if strict || c.Spec.ControlPlaneKubelet.NonMasqueradeCIDR != nil { + allErrs = append(allErrs, field.Forbidden(fieldSpec.Child("controlPlaneKubelet", "nonMasqueradeCIDR"), "controlPlaneKubelet nonMasqueradeCIDR did not match cluster nonMasqueradeCIDR")) } } } @@ -280,8 +280,8 @@ func ValidateCluster(c *kops.Cluster, strict bool) field.ErrorList { if isExperimentalClusterDNS(c.Spec.Kubelet, c.Spec.KubeDNS) { allErrs = append(allErrs, field.Forbidden(fieldSpec.Child("kubelet", "clusterDNS"), "Kubelet ClusterDNS did not match cluster kubeDNS.serverIP or nodeLocalDNS.localIP")) } - if isExperimentalClusterDNS(c.Spec.MasterKubelet, c.Spec.KubeDNS) { - allErrs = append(allErrs, field.Forbidden(fieldSpec.Child("masterKubelet", "clusterDNS"), "MasterKubelet ClusterDNS did not match cluster kubeDNS.serverIP or nodeLocalDNS.localIP")) + if isExperimentalClusterDNS(c.Spec.ControlPlaneKubelet, c.Spec.KubeDNS) { + allErrs = append(allErrs, field.Forbidden(fieldSpec.Child("controlPlaneKubelet", "clusterDNS"), "ControlPlaneKubelet ClusterDNS did not match cluster kubeDNS.serverIP or nodeLocalDNS.localIP")) } } } @@ -344,9 +344,9 @@ func ValidateCluster(c *kops.Cluster, strict bool) field.ErrorList { allErrs = append(allErrs, field.Forbidden(fieldSpec.Child("kubelet", "cloudProvider"), "Did not match cluster cloudProvider")) } } - if c.Spec.MasterKubelet != nil && (strict || c.Spec.MasterKubelet.CloudProvider != "") { - if c.Spec.MasterKubelet.CloudProvider != "external" && k8sCloudProvider != c.Spec.MasterKubelet.CloudProvider { - allErrs = append(allErrs, field.Forbidden(fieldSpec.Child("masterKubelet", "cloudProvider"), "Did not match cluster cloudProvider")) + if c.Spec.ControlPlaneKubelet != nil && (strict || c.Spec.ControlPlaneKubelet.CloudProvider != "") { + if c.Spec.ControlPlaneKubelet.CloudProvider != "external" && k8sCloudProvider != c.Spec.ControlPlaneKubelet.CloudProvider { + allErrs = append(allErrs, field.Forbidden(fieldSpec.Child("controlPlaneKubelet", "cloudProvider"), "Did not match cluster cloudProvider")) } } if c.Spec.KubeAPIServer != nil && (strict || c.Spec.KubeAPIServer.CloudProvider != "") { diff --git a/pkg/apis/kops/validation/validation.go b/pkg/apis/kops/validation/validation.go index 9b0b3227e7..3130863261 100644 --- a/pkg/apis/kops/validation/validation.go +++ b/pkg/apis/kops/validation/validation.go @@ -154,8 +154,8 @@ func validateClusterSpec(spec *kops.ClusterSpec, c *kops.Cluster, fieldPath *fie allErrs = append(allErrs, validateKubelet(spec.Kubelet, c, fieldPath.Child("kubelet"))...) } - if spec.MasterKubelet != nil { - allErrs = append(allErrs, validateKubelet(spec.MasterKubelet, c, fieldPath.Child("masterKubelet"))...) + if spec.ControlPlaneKubelet != nil { + allErrs = append(allErrs, validateKubelet(spec.ControlPlaneKubelet, c, fieldPath.Child("controlPlaneKubelet"))...) } if spec.Networking != nil { @@ -1586,8 +1586,8 @@ func validateNodeLocalDNS(spec *kops.ClusterSpec, fldpath *field.Path) field.Err allErrs = append(allErrs, field.Forbidden(fldpath.Child("kubelet", "clusterDNS"), "Kubelet ClusterDNS must be set to the default IP address for LocalIP")) } - if spec.MasterKubelet != nil && spec.MasterKubelet.ClusterDNS != "" && spec.MasterKubelet.ClusterDNS != spec.KubeDNS.NodeLocalDNS.LocalIP { - allErrs = append(allErrs, field.Forbidden(fldpath.Child("kubelet", "clusterDNS"), "MasterKubelet ClusterDNS must be set to the default IP address for LocalIP")) + if spec.ControlPlaneKubelet != nil && spec.ControlPlaneKubelet.ClusterDNS != "" && spec.ControlPlaneKubelet.ClusterDNS != spec.KubeDNS.NodeLocalDNS.LocalIP { + allErrs = append(allErrs, field.Forbidden(fldpath.Child("kubelet", "clusterDNS"), "ControlPlaneKubelet ClusterDNS must be set to the default IP address for LocalIP")) } } diff --git a/pkg/apis/kops/zz_generated.deepcopy.go b/pkg/apis/kops/zz_generated.deepcopy.go index 3641dbed50..c36d3045af 100644 --- a/pkg/apis/kops/zz_generated.deepcopy.go +++ b/pkg/apis/kops/zz_generated.deepcopy.go @@ -1256,8 +1256,8 @@ func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) { *out = new(KubeletConfigSpec) (*in).DeepCopyInto(*out) } - if in.MasterKubelet != nil { - in, out := &in.MasterKubelet, &out.MasterKubelet + if in.ControlPlaneKubelet != nil { + in, out := &in.ControlPlaneKubelet, &out.ControlPlaneKubelet *out = new(KubeletConfigSpec) (*in).DeepCopyInto(*out) } diff --git a/pkg/model/bootstrapscript.go b/pkg/model/bootstrapscript.go index 6a1236144f..9eeb329390 100644 --- a/pkg/model/bootstrapscript.go +++ b/pkg/model/bootstrapscript.go @@ -396,7 +396,7 @@ func (b *BootstrapScript) Run(c *fi.Context) error { spec["kubeAPIServer"] = cs.KubeAPIServer spec["kubeControllerManager"] = cs.KubeControllerManager spec["kubeScheduler"] = cs.KubeScheduler - spec["masterKubelet"] = cs.MasterKubelet + spec["masterKubelet"] = cs.ControlPlaneKubelet for _, etcdCluster := range cs.EtcdClusters { c := kops.EtcdClusterSpec{ diff --git a/pkg/model/bootstrapscript_test.go b/pkg/model/bootstrapscript_test.go index 626b6a494b..d4cecfb2b2 100644 --- a/pkg/model/bootstrapscript_test.go +++ b/pkg/model/bootstrapscript_test.go @@ -278,7 +278,7 @@ func makeTestCluster(hookSpecRoles []kops.InstanceGroupRole, fileAssetSpecRoles Kubelet: &kops.KubeletConfigSpec{ KubeconfigPath: "/etc/kubernetes/config.txt", }, - MasterKubelet: &kops.KubeletConfigSpec{ + ControlPlaneKubelet: &kops.KubeletConfigSpec{ KubeconfigPath: "/etc/kubernetes/config.cfg", }, EgressProxy: &kops.EgressProxySpec{ diff --git a/pkg/model/components/kubelet.go b/pkg/model/components/kubelet.go index 1c8d82af72..93c6a46c6b 100644 --- a/pkg/model/components/kubelet.go +++ b/pkg/model/components/kubelet.go @@ -44,8 +44,8 @@ func (b *KubeletOptionsBuilder) BuildOptions(o interface{}) error { if clusterSpec.Kubelet == nil { clusterSpec.Kubelet = &kops.KubeletConfigSpec{} } - if clusterSpec.MasterKubelet == nil { - clusterSpec.MasterKubelet = &kops.KubeletConfigSpec{} + if clusterSpec.ControlPlaneKubelet == nil { + clusterSpec.ControlPlaneKubelet = &kops.KubeletConfigSpec{} } if clusterSpec.KubeAPIServer != nil && clusterSpec.KubeAPIServer.EnableBootstrapAuthToken != nil { @@ -86,11 +86,11 @@ func (b *KubeletOptionsBuilder) BuildOptions(o interface{}) error { } } - clusterSpec.MasterKubelet.RegisterSchedulable = fi.PtrTo(false) + clusterSpec.ControlPlaneKubelet.RegisterSchedulable = fi.PtrTo(false) // Replace the CIDR with a CIDR allocated by KCM (the default, but included for clarity) // We _do_ allow debugging handlers, so we can do logs // This does allow more access than we would like though - clusterSpec.MasterKubelet.EnableDebuggingHandlers = fi.PtrTo(true) + clusterSpec.ControlPlaneKubelet.EnableDebuggingHandlers = fi.PtrTo(true) { // For pod eviction in low memory or empty disk situations @@ -113,13 +113,13 @@ func (b *KubeletOptionsBuilder) BuildOptions(o interface{}) error { // use kubeconfig instead of api-servers const kubeconfigPath = "/var/lib/kubelet/kubeconfig" clusterSpec.Kubelet.KubeconfigPath = kubeconfigPath - clusterSpec.MasterKubelet.KubeconfigPath = kubeconfigPath + clusterSpec.ControlPlaneKubelet.KubeconfigPath = kubeconfigPath // IsolateMasters enables the legacy behaviour, where master pods on a separate network // In newer versions of kubernetes, most of that functionality has been removed though if fi.ValueOf(clusterSpec.IsolateMasters) { - clusterSpec.MasterKubelet.EnableDebuggingHandlers = fi.PtrTo(false) - clusterSpec.MasterKubelet.HairpinMode = "none" + clusterSpec.ControlPlaneKubelet.EnableDebuggingHandlers = fi.PtrTo(false) + clusterSpec.ControlPlaneKubelet.HairpinMode = "none" } cloudProvider := clusterSpec.GetCloudProvider() @@ -218,7 +218,7 @@ func (b *KubeletOptionsBuilder) BuildOptions(o interface{}) error { } clusterSpec.Kubelet.RegisterSchedulable = fi.PtrTo(true) - clusterSpec.MasterKubelet.RegisterSchedulable = fi.PtrTo(true) + clusterSpec.ControlPlaneKubelet.RegisterSchedulable = fi.PtrTo(true) return nil } diff --git a/pkg/nodelabels/builder.go b/pkg/nodelabels/builder.go index cb91c1e17e..4a82779260 100644 --- a/pkg/nodelabels/builder.go +++ b/pkg/nodelabels/builder.go @@ -45,7 +45,7 @@ func BuildNodeLabels(cluster *kops.Cluster, instanceGroup *kops.InstanceGroup) m // Merge KubeletConfig for NodeLabels c := &kops.KubeletConfigSpec{} if isControlPlane { - reflectutils.JSONMergeStruct(c, cluster.Spec.MasterKubelet) + reflectutils.JSONMergeStruct(c, cluster.Spec.ControlPlaneKubelet) } else { reflectutils.JSONMergeStruct(c, cluster.Spec.Kubelet) } diff --git a/pkg/nodelabels/builder_test.go b/pkg/nodelabels/builder_test.go index 4526410f2a..d4519fd958 100644 --- a/pkg/nodelabels/builder_test.go +++ b/pkg/nodelabels/builder_test.go @@ -35,7 +35,7 @@ func TestBuildNodeLabels(t *testing.T) { cluster: &kops.Cluster{ Spec: kops.ClusterSpec{ KubernetesVersion: "v1.9.0", - MasterKubelet: &kops.KubeletConfigSpec{ + ControlPlaneKubelet: &kops.KubeletConfigSpec{ NodeLabels: map[string]string{ "controlPlane1": "controlPlane1", "controlPlane2": "controlPlane2", @@ -78,7 +78,7 @@ func TestBuildNodeLabels(t *testing.T) { cluster: &kops.Cluster{ Spec: kops.ClusterSpec{ KubernetesVersion: "v1.9.0", - MasterKubelet: &kops.KubeletConfigSpec{ + ControlPlaneKubelet: &kops.KubeletConfigSpec{ NodeLabels: map[string]string{ "controlPlane1": "controlPlane1", "controlPlane2": "controlPlane2", diff --git a/tests/integration/conversion/aws/v1alpha2.yaml b/tests/integration/conversion/aws/v1alpha2.yaml index 8580ad452a..8ee665c4d8 100644 --- a/tests/integration/conversion/aws/v1alpha2.yaml +++ b/tests/integration/conversion/aws/v1alpha2.yaml @@ -53,6 +53,8 @@ spec: kubernetesApiAccess: - 0.0.0.0/0 kubernetesVersion: v1.21.0 + masterKubelet: + cpuCFSQuota: true masterPublicName: api.minimal.example.com networkCIDR: 172.20.0.0/16 networking: diff --git a/tests/integration/conversion/aws/v1alpha3.yaml b/tests/integration/conversion/aws/v1alpha3.yaml index 75c5627b1e..43c8c18a0a 100644 --- a/tests/integration/conversion/aws/v1alpha3.yaml +++ b/tests/integration/conversion/aws/v1alpha3.yaml @@ -25,6 +25,8 @@ spec: cloudProvider: aws: {} configBase: memfs://clusters.example.com/minimal.example.com + controlPlaneKubelet: + cpuCFSQuota: true etcdClusters: - cpuRequest: 200m etcdMembers: diff --git a/upup/pkg/fi/cloudup/populate_cluster_spec_test.go b/upup/pkg/fi/cloudup/populate_cluster_spec_test.go index 981cc5eb23..abbd69586e 100644 --- a/upup/pkg/fi/cloudup/populate_cluster_spec_test.go +++ b/upup/pkg/fi/cloudup/populate_cluster_spec_test.go @@ -253,11 +253,11 @@ func TestPopulateCluster_IsolateMasters(t *testing.T) { if err != nil { t.Fatalf("Unexpected error from PopulateCluster: %v", err) } - if fi.ValueOf(full.Spec.MasterKubelet.EnableDebuggingHandlers) != false { - t.Fatalf("Unexpected EnableDebuggingHandlers: %v", fi.ValueOf(full.Spec.MasterKubelet.EnableDebuggingHandlers)) + if fi.ValueOf(full.Spec.ControlPlaneKubelet.EnableDebuggingHandlers) != false { + t.Fatalf("Unexpected EnableDebuggingHandlers: %v", fi.ValueOf(full.Spec.ControlPlaneKubelet.EnableDebuggingHandlers)) } - if fi.ValueOf(full.Spec.MasterKubelet.ReconcileCIDR) != false { - t.Fatalf("Unexpected ReconcileCIDR: %v", fi.ValueOf(full.Spec.MasterKubelet.ReconcileCIDR)) + if fi.ValueOf(full.Spec.ControlPlaneKubelet.ReconcileCIDR) != false { + t.Fatalf("Unexpected ReconcileCIDR: %v", fi.ValueOf(full.Spec.ControlPlaneKubelet.ReconcileCIDR)) } } @@ -274,8 +274,8 @@ func TestPopulateCluster_IsolateMastersFalse(t *testing.T) { if err != nil { t.Fatalf("Unexpected error from PopulateCluster: %v", err) } - if fi.ValueOf(full.Spec.MasterKubelet.EnableDebuggingHandlers) != true { - t.Fatalf("Unexpected EnableDebuggingHandlers: %v", fi.ValueOf(full.Spec.MasterKubelet.EnableDebuggingHandlers)) + if fi.ValueOf(full.Spec.ControlPlaneKubelet.EnableDebuggingHandlers) != true { + t.Fatalf("Unexpected EnableDebuggingHandlers: %v", fi.ValueOf(full.Spec.ControlPlaneKubelet.EnableDebuggingHandlers)) } } diff --git a/upup/pkg/fi/cloudup/populate_instancegroup_spec.go b/upup/pkg/fi/cloudup/populate_instancegroup_spec.go index c6e73a2142..96154144ac 100644 --- a/upup/pkg/fi/cloudup/populate_instancegroup_spec.go +++ b/upup/pkg/fi/cloudup/populate_instancegroup_spec.go @@ -234,12 +234,12 @@ func PopulateInstanceGroupSpec(cluster *kops.Cluster, input *kops.InstanceGroup, var igKubeletConfig *kops.KubeletConfigSpec // Start with the cluster kubelet config if ig.IsControlPlane() { - if cluster.Spec.MasterKubelet != nil { - igKubeletConfig = cluster.Spec.MasterKubelet.DeepCopy() + if cluster.Spec.ControlPlaneKubelet != nil { + igKubeletConfig = cluster.Spec.ControlPlaneKubelet.DeepCopy() } else { igKubeletConfig = &kops.KubeletConfigSpec{} } - // A few settings in Kubelet override those in MasterKubelet. I'm not sure why. + // A few settings in Kubelet override those in ControlPlaneKubelet. I'm not sure why. if cluster.Spec.Kubelet != nil && cluster.Spec.Kubelet.AnonymousAuth != nil && !*cluster.Spec.Kubelet.AnonymousAuth { igKubeletConfig.AnonymousAuth = fi.PtrTo(false) } diff --git a/upup/pkg/fi/cloudup/populate_instancegroup_spec_test.go b/upup/pkg/fi/cloudup/populate_instancegroup_spec_test.go index 46c5c7565e..3f8e3d4e30 100644 --- a/upup/pkg/fi/cloudup/populate_instancegroup_spec_test.go +++ b/upup/pkg/fi/cloudup/populate_instancegroup_spec_test.go @@ -172,7 +172,7 @@ func TestPopulateInstanceGroup_EvictionHard3(t *testing.T) { func TestPopulateInstanceGroup_EvictionHard4(t *testing.T) { _, cluster := buildMinimalCluster() - cluster.Spec.MasterKubelet = &kopsapi.KubeletConfigSpec{ + cluster.Spec.ControlPlaneKubelet = &kopsapi.KubeletConfigSpec{ EvictionHard: fi.PtrTo("memory.available<350Mi"), } input := buildMinimalMasterInstanceGroup("us-test-1") diff --git a/upup/pkg/fi/cloudup/spec_builder.go b/upup/pkg/fi/cloudup/spec_builder.go index e8b6934d70..fd6abfdad7 100644 --- a/upup/pkg/fi/cloudup/spec_builder.go +++ b/upup/pkg/fi/cloudup/spec_builder.go @@ -36,11 +36,11 @@ func (l *SpecBuilder) BuildCompleteSpec(clusterSpec *kopsapi.ClusterSpec) (*kops completed := &kopsapi.ClusterSpec{} *completed = *(loaded.(*kopsapi.ClusterSpec)) - // Master kubelet config = (base kubelet config + master kubelet config) - masterKubelet := &kopsapi.KubeletConfigSpec{} - reflectutils.JSONMergeStruct(masterKubelet, completed.Kubelet) - reflectutils.JSONMergeStruct(masterKubelet, completed.MasterKubelet) - completed.MasterKubelet = masterKubelet + // Control-plane kubelet config = (base kubelet config + control-plane kubelet config) + controlPlaneKubelet := &kopsapi.KubeletConfigSpec{} + reflectutils.JSONMergeStruct(controlPlaneKubelet, completed.Kubelet) + reflectutils.JSONMergeStruct(controlPlaneKubelet, completed.ControlPlaneKubelet) + completed.ControlPlaneKubelet = controlPlaneKubelet klog.V(1).Infof("options: %s", fi.DebugAsJsonStringIndent(completed)) return completed, nil