diff --git a/pkg/providers/tinkerbell/config/template-cp.yaml b/pkg/providers/tinkerbell/config/template-cp.yaml index 44748658bff83..0dad96966e85a 100644 --- a/pkg/providers/tinkerbell/config/template-cp.yaml +++ b/pkg/providers/tinkerbell/config/template-cp.yaml @@ -253,10 +253,10 @@ spec: files: {{- if .kubeletConfiguration }} - content: | -{{ .kubeletConfiguration | indent 10}} - owner: root:root - permissions: "0644" - path: /etc/kubernetes/patches/kubeletconfiguration0+strategic.yaml +{{ .kubeletConfiguration | indent 10 }} + owner: root:root + permissions: "0644" + path: /etc/kubernetes/patches/kubeletconfiguration0+strategic.yaml {{- end }} {{- if not .cpSkipLoadBalancerDeployment }} - content: | diff --git a/pkg/providers/tinkerbell/config/template-md.yaml b/pkg/providers/tinkerbell/config/template-md.yaml index 856481daa3940..7d52696796271 100644 --- a/pkg/providers/tinkerbell/config/template-md.yaml +++ b/pkg/providers/tinkerbell/config/template-md.yaml @@ -136,7 +136,7 @@ spec: files: {{- end }} {{- if .kubeletConfiguration }} - - content: | + - content: | {{ .kubeletConfiguration | indent 10 }} owner: root:root permissions: "0644" diff --git a/pkg/providers/tinkerbell/template_test.go b/pkg/providers/tinkerbell/template_test.go index 284523e00e897..f16dddcff5b79 100644 --- a/pkg/providers/tinkerbell/template_test.go +++ b/pkg/providers/tinkerbell/template_test.go @@ -1,10 +1,11 @@ package tinkerbell - + import ( "testing" "time" . "github.com/onsi/gomega" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "github.com/aws/eks-anywhere/internal/test" "github.com/aws/eks-anywhere/pkg/api/v1alpha1" @@ -195,3 +196,38 @@ func TestTemplateBuilder(t *testing.T) { } } + +func TestTemplateBuilderCPKubeletConfig(t *testing.T) { + for _, tc := range []struct { + Input string + Output string + }{ + { + Input: "testdata/cluster_tinkerbell_api_server_cert_san_ip.yaml", + Output: "testdata/expected_cluster_tinkerbell_api_server_cert_san_ip.yaml", + }, + } { + g := NewWithT(t) + clusterSpec := test.NewFullClusterSpec(t, tc.Input) + + cpMachineCfg, _ := getControlPlaneMachineSpec(clusterSpec) + wngMachineCfgs, _ := getWorkerNodeGroupMachineSpec(clusterSpec) + + tinkIPBefore := "0.0.0.0" + bldr := NewTemplateBuilder(&clusterSpec.TinkerbellDatacenter.Spec, cpMachineCfg, nil, wngMachineCfgs, tinkIPBefore, time.Now) + + clusterSpec.Cluster.Spec.ControlPlaneConfiguration.KubeletConfiguration = &unstructured.Unstructured{ + Object: map[string]interface{}{ + "maxPods": 20, + "apiVersion": "kubelet.config.k8s.io/v1beta1", + "kind": "KubeletConfiguration", + }, + } + + data, err := bldr.GenerateCAPISpecControlPlane(clusterSpec) + g.Expect(err).ToNot(HaveOccurred()) + + g.Expect(data).To(ContainSubstring("maxPods")) + + } +}