From 4ab9465152f05a669f0dc7cae9fd1a6b5947c42d Mon Sep 17 00:00:00 2001 From: Michael Irwin Date: Thu, 16 Dec 2021 12:40:14 -0500 Subject: [PATCH 1/8] Add ability to specify ClusterDNSIP Signed-off-by: Michael Irwin Resolves #928 --- .../crds/karpenter.sh_provisioners.yaml | 8 +++++++ pkg/apis/provisioning/v1alpha5/constraints.go | 4 ++++ .../provisioning/v1alpha5/kubelet_args.go | 22 +++++++++++++++++++ .../v1alpha5/zz_generated.deepcopy.go | 16 ++++++++++++++ pkg/cloudprovider/aws/launchtemplate.go | 4 ++++ website/content/en/docs/provisioner.md | 12 ++++++++++ 6 files changed, 66 insertions(+) create mode 100644 pkg/apis/provisioning/v1alpha5/kubelet_args.go diff --git a/charts/karpenter/crds/karpenter.sh_provisioners.yaml b/charts/karpenter/crds/karpenter.sh_provisioners.yaml index 6abdc67d8727..8477747d32bb 100644 --- a/charts/karpenter/crds/karpenter.sh_provisioners.yaml +++ b/charts/karpenter/crds/karpenter.sh_provisioners.yaml @@ -40,6 +40,14 @@ spec: Node properties are determined from a combination of provisioner and pod scheduling constraints. properties: + kubeletArgs: + description: KubeletArgs define args to be used when configuring kubelet + on provisioned nodes + properties: + clusterDnsIp: + description: The IP address for in-cluster DNS resolution + type: string + type: object labels: additionalProperties: type: string diff --git a/pkg/apis/provisioning/v1alpha5/constraints.go b/pkg/apis/provisioning/v1alpha5/constraints.go index c295446e3904..b4d73f4f615d 100644 --- a/pkg/apis/provisioning/v1alpha5/constraints.go +++ b/pkg/apis/provisioning/v1alpha5/constraints.go @@ -34,6 +34,9 @@ type Constraints struct { Taints Taints `json:"taints,omitempty"` // Requirements are layered with Labels and applied to every node. Requirements Requirements `json:"requirements,omitempty"` + // KubeletArgs define args to be used when configuring kubelet on provisioned nodes + //+optional + KubeletArgs KubeletArgs `json:"kubeletArgs,omitempty"` // Provider contains fields specific to your cloudprovider. // +kubebuilder:pruning:PreserveUnknownFields Provider *runtime.RawExtension `json:"provider,omitempty"` @@ -68,5 +71,6 @@ func (c *Constraints) Tighten(pod *v1.Pod) *Constraints { Requirements: c.Requirements.With(PodRequirements(pod)).Consolidate().WellKnown(), Taints: c.Taints, Provider: c.Provider, + KubeletArgs: c.KubeletArgs, } } diff --git a/pkg/apis/provisioning/v1alpha5/kubelet_args.go b/pkg/apis/provisioning/v1alpha5/kubelet_args.go new file mode 100644 index 000000000000..f2d329446953 --- /dev/null +++ b/pkg/apis/provisioning/v1alpha5/kubelet_args.go @@ -0,0 +1,22 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha5 + +// KubeletArgs define args to be used when configuring kubelet on provisioned nodes +type KubeletArgs struct { + // The IP address for in-cluster DNS resolution + //+optional + ClusterDNSIP string `json:"clusterDnsIp"` +} diff --git a/pkg/apis/provisioning/v1alpha5/zz_generated.deepcopy.go b/pkg/apis/provisioning/v1alpha5/zz_generated.deepcopy.go index b38194d722ab..7f868b8999db 100644 --- a/pkg/apis/provisioning/v1alpha5/zz_generated.deepcopy.go +++ b/pkg/apis/provisioning/v1alpha5/zz_generated.deepcopy.go @@ -49,6 +49,7 @@ func (in *Constraints) DeepCopyInto(out *Constraints) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + out.KubeletArgs = in.KubeletArgs if in.Provider != nil { in, out := &in.Provider, &out.Provider *out = new(runtime.RawExtension) @@ -66,6 +67,21 @@ func (in *Constraints) DeepCopy() *Constraints { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KubeletArgs) DeepCopyInto(out *KubeletArgs) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeletArgs. +func (in *KubeletArgs) DeepCopy() *KubeletArgs { + if in == nil { + return nil + } + out := new(KubeletArgs) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Limits) DeepCopyInto(out *Limits) { *out = *in diff --git a/pkg/cloudprovider/aws/launchtemplate.go b/pkg/cloudprovider/aws/launchtemplate.go index ac7d5b556314..97592d5de8a2 100644 --- a/pkg/cloudprovider/aws/launchtemplate.go +++ b/pkg/cloudprovider/aws/launchtemplate.go @@ -280,6 +280,10 @@ exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1 if len(kubeletExtraArgs) > 0 { userData.WriteString(fmt.Sprintf(` \ --kubelet-extra-args '%s'`, kubeletExtraArgs)) + } + if constraints.KubeletArgs.ClusterDNSIP != "" { + userData.WriteString(fmt.Sprintf(` \ + --dns-cluster-ip '%s'`, constraints.KubeletArgs.ClusterDNSIP)) } return base64.StdEncoding.EncodeToString(userData.Bytes()), nil } diff --git a/website/content/en/docs/provisioner.md b/website/content/en/docs/provisioner.md index a22050b4c2b4..4c508f45babf 100644 --- a/website/content/en/docs/provisioner.md +++ b/website/content/en/docs/provisioner.md @@ -137,6 +137,18 @@ Karpenter supports `amd64` nodes, and `arm64` nodes. Karpenter supports specifying capacity type, which is analogous to [EC2 purchase options](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-purchasing-options.html). +## spec.kubeletArgs + +Karpenter provides the ability to specify a few additional Kubelet args. These are all optional and provide support for +additional customization and use cases. Adjust these only if you know you need to do so. + +```yaml +spec: + kubeletArgs: + clusterDNSIP: 10.0.1.100 +``` + + ## spec.provider This section is cloud provider specific. Reference the appropriate documentation: From 33e46b14df77dda67524037f82565310c23e7b63 Mon Sep 17 00:00:00 2001 From: Michael Irwin Date: Thu, 16 Dec 2021 14:26:52 -0500 Subject: [PATCH 2/8] Add unit test to validate clusterDNSIP setting Signed-off-by: Michael Irwin --- pkg/cloudprovider/aws/suite_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/cloudprovider/aws/suite_test.go b/pkg/cloudprovider/aws/suite_test.go index f0e7a21f80d2..839639879498 100644 --- a/pkg/cloudprovider/aws/suite_test.go +++ b/pkg/cloudprovider/aws/suite_test.go @@ -16,6 +16,7 @@ package aws import ( "context" + "encoding/base64" "encoding/json" "testing" @@ -407,6 +408,17 @@ var _ = Describe("Allocation", func() { )) }) }) + Context("Kubelet Args", func() { + It("should specify the --dns-cluster-ip flag when clusterDNSIP is set", func() { + provisioner.Spec.KubeletArgs.ClusterDNSIP = "10.0.10.100" + pod := ExpectProvisioned(ctx, env.Client, selectionController, provisioners, ProvisionerWithProvider(provisioner, provider), test.UnschedulablePod())[0] + ExpectScheduled(ctx, env.Client, pod) + Expect(fakeEC2API.CalledWithCreateLaunchTemplateInput.Cardinality()).To(Equal(1)) + input := fakeEC2API.CalledWithCreateLaunchTemplateInput.Pop().(*ec2.CreateLaunchTemplateInput) + userData, _ := base64.StdEncoding.DecodeString(*input.LaunchTemplateData.UserData) + Expect(string(userData)).To(ContainSubstring("--dns-cluster-ip '10.0.10.100'")) + }) + }) }) Context("Defaulting", func() { It("should default subnetSelector", func() { From 472937bb73c7df17ec2b16b3f5eb986b126de2d3 Mon Sep 17 00:00:00 2001 From: Michael Irwin Date: Thu, 16 Dec 2021 14:42:46 -0500 Subject: [PATCH 3/8] Update pkg/apis/provisioning/v1alpha5/constraints.go Co-authored-by: Ellis Tarn --- pkg/apis/provisioning/v1alpha5/constraints.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/apis/provisioning/v1alpha5/constraints.go b/pkg/apis/provisioning/v1alpha5/constraints.go index b4d73f4f615d..ca67f5464e20 100644 --- a/pkg/apis/provisioning/v1alpha5/constraints.go +++ b/pkg/apis/provisioning/v1alpha5/constraints.go @@ -34,7 +34,7 @@ type Constraints struct { Taints Taints `json:"taints,omitempty"` // Requirements are layered with Labels and applied to every node. Requirements Requirements `json:"requirements,omitempty"` - // KubeletArgs define args to be used when configuring kubelet on provisioned nodes + // KubeletArgs are passed to the kubelet when provisioning nodes //+optional KubeletArgs KubeletArgs `json:"kubeletArgs,omitempty"` // Provider contains fields specific to your cloudprovider. From e2bc665ce324da28372bb840c07ce7f05b577c17 Mon Sep 17 00:00:00 2001 From: Michael Irwin Date: Thu, 16 Dec 2021 16:15:47 -0500 Subject: [PATCH 4/8] Rename kubelet args to align with kubelet types Signed-off-by: Michael Irwin --- charts/karpenter/crds/karpenter.sh_provisioners.yaml | 9 ++++++--- pkg/apis/provisioning/v1alpha5/kubelet_args.go | 9 ++++++--- pkg/apis/provisioning/v1alpha5/zz_generated.deepcopy.go | 7 ++++++- pkg/cloudprovider/aws/launchtemplate.go | 4 ++-- pkg/cloudprovider/aws/suite_test.go | 2 +- website/content/en/docs/provisioner.md | 2 +- 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/charts/karpenter/crds/karpenter.sh_provisioners.yaml b/charts/karpenter/crds/karpenter.sh_provisioners.yaml index 8477747d32bb..0ee1f119e531 100644 --- a/charts/karpenter/crds/karpenter.sh_provisioners.yaml +++ b/charts/karpenter/crds/karpenter.sh_provisioners.yaml @@ -44,9 +44,12 @@ spec: description: KubeletArgs define args to be used when configuring kubelet on provisioned nodes properties: - clusterDnsIp: - description: The IP address for in-cluster DNS resolution - type: string + clusterDns: + description: clusterDNS is a list of IP addresses for the cluster + DNS server. Note that not all providers may use all addresses. + items: + type: string + type: array type: object labels: additionalProperties: diff --git a/pkg/apis/provisioning/v1alpha5/kubelet_args.go b/pkg/apis/provisioning/v1alpha5/kubelet_args.go index f2d329446953..cc7ff9493799 100644 --- a/pkg/apis/provisioning/v1alpha5/kubelet_args.go +++ b/pkg/apis/provisioning/v1alpha5/kubelet_args.go @@ -14,9 +14,12 @@ limitations under the License. package v1alpha5 -// KubeletArgs define args to be used when configuring kubelet on provisioned nodes +// KubeletArgs define args to be used when configuring kubelet on provisioned nodes. +// They are a subset of the upstream types, recognizing not all options may be supported. +// Wherever possible, the types and names should reflect the upstream kubelet types. type KubeletArgs struct { - // The IP address for in-cluster DNS resolution + // clusterDNS is a list of IP addresses for the cluster DNS server. + // Note that not all providers may use all addresses. //+optional - ClusterDNSIP string `json:"clusterDnsIp"` + ClusterDNS []string `json:"clusterDns,omitempty"` } diff --git a/pkg/apis/provisioning/v1alpha5/zz_generated.deepcopy.go b/pkg/apis/provisioning/v1alpha5/zz_generated.deepcopy.go index 7f868b8999db..fd6760eb8ca0 100644 --- a/pkg/apis/provisioning/v1alpha5/zz_generated.deepcopy.go +++ b/pkg/apis/provisioning/v1alpha5/zz_generated.deepcopy.go @@ -49,7 +49,7 @@ func (in *Constraints) DeepCopyInto(out *Constraints) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - out.KubeletArgs = in.KubeletArgs + in.KubeletArgs.DeepCopyInto(&out.KubeletArgs) if in.Provider != nil { in, out := &in.Provider, &out.Provider *out = new(runtime.RawExtension) @@ -70,6 +70,11 @@ func (in *Constraints) DeepCopy() *Constraints { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KubeletArgs) DeepCopyInto(out *KubeletArgs) { *out = *in + if in.ClusterDNS != nil { + in, out := &in.ClusterDNS, &out.ClusterDNS + *out = make([]string, len(*in)) + copy(*out, *in) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeletArgs. diff --git a/pkg/cloudprovider/aws/launchtemplate.go b/pkg/cloudprovider/aws/launchtemplate.go index 97592d5de8a2..6f260ff56bda 100644 --- a/pkg/cloudprovider/aws/launchtemplate.go +++ b/pkg/cloudprovider/aws/launchtemplate.go @@ -281,9 +281,9 @@ exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1 userData.WriteString(fmt.Sprintf(` \ --kubelet-extra-args '%s'`, kubeletExtraArgs)) } - if constraints.KubeletArgs.ClusterDNSIP != "" { + if len(constraints.KubeletArgs.ClusterDNS) > 0 { userData.WriteString(fmt.Sprintf(` \ - --dns-cluster-ip '%s'`, constraints.KubeletArgs.ClusterDNSIP)) + --dns-cluster-ip '%s'`, constraints.KubeletArgs.ClusterDNS[0])) } return base64.StdEncoding.EncodeToString(userData.Bytes()), nil } diff --git a/pkg/cloudprovider/aws/suite_test.go b/pkg/cloudprovider/aws/suite_test.go index 839639879498..863252135f28 100644 --- a/pkg/cloudprovider/aws/suite_test.go +++ b/pkg/cloudprovider/aws/suite_test.go @@ -410,7 +410,7 @@ var _ = Describe("Allocation", func() { }) Context("Kubelet Args", func() { It("should specify the --dns-cluster-ip flag when clusterDNSIP is set", func() { - provisioner.Spec.KubeletArgs.ClusterDNSIP = "10.0.10.100" + provisioner.Spec.KubeletArgs.ClusterDNS = []string{"10.0.10.100"} pod := ExpectProvisioned(ctx, env.Client, selectionController, provisioners, ProvisionerWithProvider(provisioner, provider), test.UnschedulablePod())[0] ExpectScheduled(ctx, env.Client, pod) Expect(fakeEC2API.CalledWithCreateLaunchTemplateInput.Cardinality()).To(Equal(1)) diff --git a/website/content/en/docs/provisioner.md b/website/content/en/docs/provisioner.md index 4c508f45babf..9805594cf8c7 100644 --- a/website/content/en/docs/provisioner.md +++ b/website/content/en/docs/provisioner.md @@ -145,7 +145,7 @@ additional customization and use cases. Adjust these only if you know you need t ```yaml spec: kubeletArgs: - clusterDNSIP: 10.0.1.100 + clusterDNS: ["10.0.1.100"] ``` From d1b4ef18b73dcb744456b2645a2f31591e6bb500 Mon Sep 17 00:00:00 2001 From: Michael Irwin Date: Thu, 16 Dec 2021 16:23:48 -0500 Subject: [PATCH 5/8] CRD docs update Signed-off-by: Michael Irwin --- charts/karpenter/crds/karpenter.sh_provisioners.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/karpenter/crds/karpenter.sh_provisioners.yaml b/charts/karpenter/crds/karpenter.sh_provisioners.yaml index 0ee1f119e531..ef3501d99c62 100644 --- a/charts/karpenter/crds/karpenter.sh_provisioners.yaml +++ b/charts/karpenter/crds/karpenter.sh_provisioners.yaml @@ -41,8 +41,8 @@ spec: pod scheduling constraints. properties: kubeletArgs: - description: KubeletArgs define args to be used when configuring kubelet - on provisioned nodes + description: KubeletArgs are passed to the kubelet when provisioning + nodes properties: clusterDns: description: clusterDNS is a list of IP addresses for the cluster From bb15d1cd74d95807ed6ddb67d85562d3af80d61d Mon Sep 17 00:00:00 2001 From: Michael Irwin Date: Thu, 16 Dec 2021 17:10:49 -0500 Subject: [PATCH 6/8] Refactored userData creation to reduce code complexity Signed-off-by: Michael Irwin --- pkg/cloudprovider/aws/launchtemplate.go | 32 ++++++++++++++++--------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/pkg/cloudprovider/aws/launchtemplate.go b/pkg/cloudprovider/aws/launchtemplate.go index 6f260ff56bda..c8a08d07cd6e 100644 --- a/pkg/cloudprovider/aws/launchtemplate.go +++ b/pkg/cloudprovider/aws/launchtemplate.go @@ -247,7 +247,22 @@ exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1 *caBundle)) } - nodeLabels := functional.UnionStringMaps(additionalLabels, constraints.Labels) + nodeLabelArgs := p.getNodeLabelArgs(functional.UnionStringMaps(additionalLabels, constraints.Labels)) + nodeTaintsArgs := p.getNodeTaintArgs(constraints) + kubeletExtraArgs := strings.Trim(strings.Join([]string{nodeLabelArgs, nodeTaintsArgs.String()}, " "), " ") + + if len(kubeletExtraArgs) > 0 { + userData.WriteString(fmt.Sprintf(` \ + --kubelet-extra-args '%s'`, kubeletExtraArgs)) + } + if len(constraints.KubeletArgs.ClusterDNS) > 0 { + userData.WriteString(fmt.Sprintf(` \ + --dns-cluster-ip '%s'`, constraints.KubeletArgs.ClusterDNS[0])) + } + return base64.StdEncoding.EncodeToString(userData.Bytes()), nil +} + +func (p *LaunchTemplateProvider) getNodeLabelArgs(nodeLabels map[string]string) string { nodeLabelArgs := "" if len(nodeLabels) > 0 { labelStrings := []string{} @@ -261,6 +276,10 @@ exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1 } nodeLabelArgs = fmt.Sprintf("--node-labels=%s", strings.Join(labelStrings, ",")) } + return nodeLabelArgs +} + +func (p *LaunchTemplateProvider) getNodeTaintArgs(constraints *v1alpha1.Constraints) bytes.Buffer { var nodeTaintsArgs bytes.Buffer if len(constraints.Taints) > 0 { nodeTaintsArgs.WriteString("--register-with-taints=") @@ -276,16 +295,7 @@ exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1 nodeTaintsArgs.WriteString(fmt.Sprintf("%s=%s:%s", taint.Key, taint.Value, taint.Effect)) } } - kubeletExtraArgs := strings.Trim(strings.Join([]string{nodeLabelArgs, nodeTaintsArgs.String()}, " "), " ") - if len(kubeletExtraArgs) > 0 { - userData.WriteString(fmt.Sprintf(` \ - --kubelet-extra-args '%s'`, kubeletExtraArgs)) - } - if len(constraints.KubeletArgs.ClusterDNS) > 0 { - userData.WriteString(fmt.Sprintf(` \ - --dns-cluster-ip '%s'`, constraints.KubeletArgs.ClusterDNS[0])) - } - return base64.StdEncoding.EncodeToString(userData.Bytes()), nil + return nodeTaintsArgs } func (p *LaunchTemplateProvider) GetCABundle(ctx context.Context) (*string, error) { From 8798c5b53dcd694678a609222d8fe465c4bb300c Mon Sep 17 00:00:00 2001 From: Michael Irwin Date: Thu, 16 Dec 2021 17:28:22 -0500 Subject: [PATCH 7/8] Rename kubeletArgs to kubeletConfiguration Signed-off-by: Michael Irwin --- .../karpenter/crds/karpenter.sh_provisioners.yaml | 6 +++--- pkg/apis/provisioning/v1alpha5/constraints.go | 14 +++++++------- .../{kubelet_args.go => kubelet_configuration.go} | 4 ++-- .../provisioning/v1alpha5/zz_generated.deepcopy.go | 10 +++++----- pkg/cloudprovider/aws/launchtemplate.go | 4 ++-- pkg/cloudprovider/aws/suite_test.go | 2 +- website/content/en/docs/provisioner.md | 4 ++-- 7 files changed, 22 insertions(+), 22 deletions(-) rename pkg/apis/provisioning/v1alpha5/{kubelet_args.go => kubelet_configuration.go} (87%) diff --git a/charts/karpenter/crds/karpenter.sh_provisioners.yaml b/charts/karpenter/crds/karpenter.sh_provisioners.yaml index ef3501d99c62..5d492adc6f89 100644 --- a/charts/karpenter/crds/karpenter.sh_provisioners.yaml +++ b/charts/karpenter/crds/karpenter.sh_provisioners.yaml @@ -40,9 +40,9 @@ spec: Node properties are determined from a combination of provisioner and pod scheduling constraints. properties: - kubeletArgs: - description: KubeletArgs are passed to the kubelet when provisioning - nodes + kubeletConfiguration: + description: KubeletConfiguration are options passed to the kubelet + when provisioning nodes properties: clusterDns: description: clusterDNS is a list of IP addresses for the cluster diff --git a/pkg/apis/provisioning/v1alpha5/constraints.go b/pkg/apis/provisioning/v1alpha5/constraints.go index ca67f5464e20..b550a52109d0 100644 --- a/pkg/apis/provisioning/v1alpha5/constraints.go +++ b/pkg/apis/provisioning/v1alpha5/constraints.go @@ -34,9 +34,9 @@ type Constraints struct { Taints Taints `json:"taints,omitempty"` // Requirements are layered with Labels and applied to every node. Requirements Requirements `json:"requirements,omitempty"` - // KubeletArgs are passed to the kubelet when provisioning nodes + // KubeletConfiguration are options passed to the kubelet when provisioning nodes //+optional - KubeletArgs KubeletArgs `json:"kubeletArgs,omitempty"` + KubeletConfiguration KubeletConfiguration `json:"kubeletConfiguration,omitempty"` // Provider contains fields specific to your cloudprovider. // +kubebuilder:pruning:PreserveUnknownFields Provider *runtime.RawExtension `json:"provider,omitempty"` @@ -67,10 +67,10 @@ func (c *Constraints) ValidatePod(pod *v1.Pod) error { func (c *Constraints) Tighten(pod *v1.Pod) *Constraints { return &Constraints{ - Labels: c.Labels, - Requirements: c.Requirements.With(PodRequirements(pod)).Consolidate().WellKnown(), - Taints: c.Taints, - Provider: c.Provider, - KubeletArgs: c.KubeletArgs, + Labels: c.Labels, + Requirements: c.Requirements.With(PodRequirements(pod)).Consolidate().WellKnown(), + Taints: c.Taints, + Provider: c.Provider, + KubeletConfiguration: c.KubeletConfiguration, } } diff --git a/pkg/apis/provisioning/v1alpha5/kubelet_args.go b/pkg/apis/provisioning/v1alpha5/kubelet_configuration.go similarity index 87% rename from pkg/apis/provisioning/v1alpha5/kubelet_args.go rename to pkg/apis/provisioning/v1alpha5/kubelet_configuration.go index cc7ff9493799..a227e592b3b1 100644 --- a/pkg/apis/provisioning/v1alpha5/kubelet_args.go +++ b/pkg/apis/provisioning/v1alpha5/kubelet_configuration.go @@ -14,10 +14,10 @@ limitations under the License. package v1alpha5 -// KubeletArgs define args to be used when configuring kubelet on provisioned nodes. +// KubeletConfiguration defines args to be used when configuring kubelet on provisioned nodes. // They are a subset of the upstream types, recognizing not all options may be supported. // Wherever possible, the types and names should reflect the upstream kubelet types. -type KubeletArgs struct { +type KubeletConfiguration struct { // clusterDNS is a list of IP addresses for the cluster DNS server. // Note that not all providers may use all addresses. //+optional diff --git a/pkg/apis/provisioning/v1alpha5/zz_generated.deepcopy.go b/pkg/apis/provisioning/v1alpha5/zz_generated.deepcopy.go index fd6760eb8ca0..f6c1da6ece96 100644 --- a/pkg/apis/provisioning/v1alpha5/zz_generated.deepcopy.go +++ b/pkg/apis/provisioning/v1alpha5/zz_generated.deepcopy.go @@ -49,7 +49,7 @@ func (in *Constraints) DeepCopyInto(out *Constraints) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - in.KubeletArgs.DeepCopyInto(&out.KubeletArgs) + in.KubeletConfiguration.DeepCopyInto(&out.KubeletConfiguration) if in.Provider != nil { in, out := &in.Provider, &out.Provider *out = new(runtime.RawExtension) @@ -68,7 +68,7 @@ func (in *Constraints) DeepCopy() *Constraints { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *KubeletArgs) DeepCopyInto(out *KubeletArgs) { +func (in *KubeletConfiguration) DeepCopyInto(out *KubeletConfiguration) { *out = *in if in.ClusterDNS != nil { in, out := &in.ClusterDNS, &out.ClusterDNS @@ -77,12 +77,12 @@ func (in *KubeletArgs) DeepCopyInto(out *KubeletArgs) { } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeletArgs. -func (in *KubeletArgs) DeepCopy() *KubeletArgs { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeletConfiguration. +func (in *KubeletConfiguration) DeepCopy() *KubeletConfiguration { if in == nil { return nil } - out := new(KubeletArgs) + out := new(KubeletConfiguration) in.DeepCopyInto(out) return out } diff --git a/pkg/cloudprovider/aws/launchtemplate.go b/pkg/cloudprovider/aws/launchtemplate.go index c8a08d07cd6e..4ca7adc323aa 100644 --- a/pkg/cloudprovider/aws/launchtemplate.go +++ b/pkg/cloudprovider/aws/launchtemplate.go @@ -255,9 +255,9 @@ exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1 userData.WriteString(fmt.Sprintf(` \ --kubelet-extra-args '%s'`, kubeletExtraArgs)) } - if len(constraints.KubeletArgs.ClusterDNS) > 0 { + if len(constraints.KubeletConfiguration.ClusterDNS) > 0 { userData.WriteString(fmt.Sprintf(` \ - --dns-cluster-ip '%s'`, constraints.KubeletArgs.ClusterDNS[0])) + --dns-cluster-ip '%s'`, constraints.KubeletConfiguration.ClusterDNS[0])) } return base64.StdEncoding.EncodeToString(userData.Bytes()), nil } diff --git a/pkg/cloudprovider/aws/suite_test.go b/pkg/cloudprovider/aws/suite_test.go index 863252135f28..a20eed791c11 100644 --- a/pkg/cloudprovider/aws/suite_test.go +++ b/pkg/cloudprovider/aws/suite_test.go @@ -410,7 +410,7 @@ var _ = Describe("Allocation", func() { }) Context("Kubelet Args", func() { It("should specify the --dns-cluster-ip flag when clusterDNSIP is set", func() { - provisioner.Spec.KubeletArgs.ClusterDNS = []string{"10.0.10.100"} + provisioner.Spec.KubeletConfiguration.ClusterDNS = []string{"10.0.10.100"} pod := ExpectProvisioned(ctx, env.Client, selectionController, provisioners, ProvisionerWithProvider(provisioner, provider), test.UnschedulablePod())[0] ExpectScheduled(ctx, env.Client, pod) Expect(fakeEC2API.CalledWithCreateLaunchTemplateInput.Cardinality()).To(Equal(1)) diff --git a/website/content/en/docs/provisioner.md b/website/content/en/docs/provisioner.md index 9805594cf8c7..d88bb50455a2 100644 --- a/website/content/en/docs/provisioner.md +++ b/website/content/en/docs/provisioner.md @@ -137,14 +137,14 @@ Karpenter supports `amd64` nodes, and `arm64` nodes. Karpenter supports specifying capacity type, which is analogous to [EC2 purchase options](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-purchasing-options.html). -## spec.kubeletArgs +## spec.kubeletConfiguration Karpenter provides the ability to specify a few additional Kubelet args. These are all optional and provide support for additional customization and use cases. Adjust these only if you know you need to do so. ```yaml spec: - kubeletArgs: + kubeletConfiguration: clusterDNS: ["10.0.1.100"] ``` From 96965e8c56b2447ebfcc46c52a7e962dbc47e1d1 Mon Sep 17 00:00:00 2001 From: Michael Irwin Date: Thu, 16 Dec 2021 22:34:43 -0500 Subject: [PATCH 8/8] Fix mismatch between struct name and JSON key Signed-off-by: Michael Irwin --- charts/karpenter/crds/karpenter.sh_provisioners.yaml | 2 +- pkg/apis/provisioning/v1alpha5/kubelet_configuration.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/karpenter/crds/karpenter.sh_provisioners.yaml b/charts/karpenter/crds/karpenter.sh_provisioners.yaml index 5d492adc6f89..ff6dac202d4d 100644 --- a/charts/karpenter/crds/karpenter.sh_provisioners.yaml +++ b/charts/karpenter/crds/karpenter.sh_provisioners.yaml @@ -44,7 +44,7 @@ spec: description: KubeletConfiguration are options passed to the kubelet when provisioning nodes properties: - clusterDns: + clusterDNS: description: clusterDNS is a list of IP addresses for the cluster DNS server. Note that not all providers may use all addresses. items: diff --git a/pkg/apis/provisioning/v1alpha5/kubelet_configuration.go b/pkg/apis/provisioning/v1alpha5/kubelet_configuration.go index a227e592b3b1..c54f9bc95614 100644 --- a/pkg/apis/provisioning/v1alpha5/kubelet_configuration.go +++ b/pkg/apis/provisioning/v1alpha5/kubelet_configuration.go @@ -21,5 +21,5 @@ type KubeletConfiguration struct { // clusterDNS is a list of IP addresses for the cluster DNS server. // Note that not all providers may use all addresses. //+optional - ClusterDNS []string `json:"clusterDns,omitempty"` + ClusterDNS []string `json:"clusterDNS,omitempty"` }