From ec2dcfca48e34dfb889a474246ffd911fd3ab3a1 Mon Sep 17 00:00:00 2001 From: Ole Markus With Date: Wed, 25 Aug 2021 12:16:32 +0200 Subject: [PATCH] Set NodeIPFamilies in ipv6 mode --- nodeup/pkg/model/cloudconfig.go | 3 +++ ...aws-cloud-controller.addons.k8s.io-k8s-1.18_content | 8 ++++++++ ...object_minimal.example.com-addons-bootstrap_content | 2 +- ...aws-cloud-controller.addons.k8s.io-k8s-1.18_content | 10 ++++++++++ ...object_minimal.example.com-addons-bootstrap_content | 2 +- .../k8s-1.18.yaml.template | 9 +++++++++ upup/pkg/fi/cloudup/template_functions.go | 2 ++ upup/pkg/fi/cloudup/template_functions_test.go | 10 ++++++++++ .../aws-cloud-controller.addons.k8s.io-k8s-1.18.yaml | 10 ++++++++++ .../awscloudcontroller/manifest.yaml | 2 +- 10 files changed, 55 insertions(+), 3 deletions(-) diff --git a/nodeup/pkg/model/cloudconfig.go b/nodeup/pkg/model/cloudconfig.go index 65806fa766..27bcc660b4 100644 --- a/nodeup/pkg/model/cloudconfig.go +++ b/nodeup/pkg/model/cloudconfig.go @@ -102,6 +102,9 @@ func (b *CloudConfigBuilder) Build(c *fi.ModelBuilderContext) error { if cloudConfig.ElbSecurityGroup != nil { lines = append(lines, "ElbSecurityGroup = "+*cloudConfig.ElbSecurityGroup) } + if b.Cluster.Spec.IsIPv6Only() { + lines = append(lines, "NodeIPFamilies = ipv6") + } case "openstack": osc := cloudConfig.Openstack if osc == nil { diff --git a/tests/integration/update_cluster/many-addons-ccm-irsa/data/aws_s3_bucket_object_minimal.example.com-addons-aws-cloud-controller.addons.k8s.io-k8s-1.18_content b/tests/integration/update_cluster/many-addons-ccm-irsa/data/aws_s3_bucket_object_minimal.example.com-addons-aws-cloud-controller.addons.k8s.io-k8s-1.18_content index a41f4abcc3..a30959cd15 100644 --- a/tests/integration/update_cluster/many-addons-ccm-irsa/data/aws_s3_bucket_object_minimal.example.com-addons-aws-cloud-controller.addons.k8s.io-k8s-1.18_content +++ b/tests/integration/update_cluster/many-addons-ccm-irsa/data/aws_s3_bucket_object_minimal.example.com-addons-aws-cloud-controller.addons.k8s.io-k8s-1.18_content @@ -23,6 +23,7 @@ spec: - --v=2 - --cloud-provider=aws - --use-service-account-credentials=true + - --cloud-config=/etc/kubernetes/cloud.config env: - name: KUBERNETES_SERVICE_HOST value: 127.0.0.1 @@ -37,6 +38,9 @@ spec: requests: cpu: 200m volumeMounts: + - mountPath: /etc/kubernetes/cloud.config + name: cloudconfig + readOnly: true - mountPath: /var/run/secrets/amazonaws.com/ name: token-amazonaws-com readOnly: true @@ -54,6 +58,10 @@ spec: - effect: NoSchedule key: node-role.kubernetes.io/master volumes: + - hostPath: + path: /etc/kubernetes/cloud.config + type: "" + name: cloudconfig - name: token-amazonaws-com projected: defaultMode: 420 diff --git a/tests/integration/update_cluster/many-addons-ccm-irsa/data/aws_s3_bucket_object_minimal.example.com-addons-bootstrap_content b/tests/integration/update_cluster/many-addons-ccm-irsa/data/aws_s3_bucket_object_minimal.example.com-addons-bootstrap_content index 93b12c0562..6fc1f21fd8 100644 --- a/tests/integration/update_cluster/many-addons-ccm-irsa/data/aws_s3_bucket_object_minimal.example.com-addons-bootstrap_content +++ b/tests/integration/update_cluster/many-addons-ccm-irsa/data/aws_s3_bucket_object_minimal.example.com-addons-bootstrap_content @@ -78,7 +78,7 @@ spec: role.kubernetes.io/networking: "1" - id: k8s-1.18 manifest: aws-cloud-controller.addons.k8s.io/k8s-1.18.yaml - manifestHash: 920c4484d1da9b60e389307e2c2884d1c1ddd5495a6f316ed962ac273111cbb9 + manifestHash: ed1e84215046c72cb056e9352a18c0f7616154e87338fd46f0fd64330850fc07 name: aws-cloud-controller.addons.k8s.io selector: k8s-addon: aws-cloud-controller.addons.k8s.io diff --git a/tests/integration/update_cluster/many-addons-ccm/data/aws_s3_bucket_object_minimal.example.com-addons-aws-cloud-controller.addons.k8s.io-k8s-1.18_content b/tests/integration/update_cluster/many-addons-ccm/data/aws_s3_bucket_object_minimal.example.com-addons-aws-cloud-controller.addons.k8s.io-k8s-1.18_content index 6165d7aa6f..53a0cb268e 100644 --- a/tests/integration/update_cluster/many-addons-ccm/data/aws_s3_bucket_object_minimal.example.com-addons-aws-cloud-controller.addons.k8s.io-k8s-1.18_content +++ b/tests/integration/update_cluster/many-addons-ccm/data/aws_s3_bucket_object_minimal.example.com-addons-aws-cloud-controller.addons.k8s.io-k8s-1.18_content @@ -23,6 +23,7 @@ spec: - --v=2 - --cloud-provider=aws - --use-service-account-credentials=true + - --cloud-config=/etc/kubernetes/cloud.config env: - name: KUBERNETES_SERVICE_HOST value: 127.0.0.1 @@ -32,6 +33,10 @@ spec: resources: requests: cpu: 200m + volumeMounts: + - mountPath: /etc/kubernetes/cloud.config + name: cloudconfig + readOnly: true hostNetwork: true nodeSelector: node-role.kubernetes.io/master: "" @@ -43,6 +48,11 @@ spec: value: "true" - effect: NoSchedule key: node-role.kubernetes.io/master + volumes: + - hostPath: + path: /etc/kubernetes/cloud.config + type: "" + name: cloudconfig updateStrategy: type: RollingUpdate diff --git a/tests/integration/update_cluster/many-addons-ccm/data/aws_s3_bucket_object_minimal.example.com-addons-bootstrap_content b/tests/integration/update_cluster/many-addons-ccm/data/aws_s3_bucket_object_minimal.example.com-addons-bootstrap_content index 8d19a4d33b..4f537faec5 100644 --- a/tests/integration/update_cluster/many-addons-ccm/data/aws_s3_bucket_object_minimal.example.com-addons-bootstrap_content +++ b/tests/integration/update_cluster/many-addons-ccm/data/aws_s3_bucket_object_minimal.example.com-addons-bootstrap_content @@ -78,7 +78,7 @@ spec: role.kubernetes.io/networking: "1" - id: k8s-1.18 manifest: aws-cloud-controller.addons.k8s.io/k8s-1.18.yaml - manifestHash: d03cdda8c8dc8cf3df62d94209cec9b7fe554616a99270882d0286906da569e8 + manifestHash: 19399435675417abed033f230cd7dc0f7e0f51a04a6430f7ff1ccc6b4ed41d2a name: aws-cloud-controller.addons.k8s.io selector: k8s-addon: aws-cloud-controller.addons.k8s.io diff --git a/upup/models/cloudup/resources/addons/aws-cloud-controller.addons.k8s.io/k8s-1.18.yaml.template b/upup/models/cloudup/resources/addons/aws-cloud-controller.addons.k8s.io/k8s-1.18.yaml.template index 5b3ca302d2..716544f3a2 100644 --- a/upup/models/cloudup/resources/addons/aws-cloud-controller.addons.k8s.io/k8s-1.18.yaml.template +++ b/upup/models/cloudup/resources/addons/aws-cloud-controller.addons.k8s.io/k8s-1.18.yaml.template @@ -40,8 +40,17 @@ spec: resources: requests: cpu: 200m + volumeMounts: + - mountPath: /etc/kubernetes/cloud.config + name: cloudconfig + readOnly: true hostNetwork: true priorityClassName: system-cluster-critical + volumes: + - hostPath: + path: /etc/kubernetes/cloud.config + type: "" + name: cloudconfig --- apiVersion: v1 kind: ServiceAccount diff --git a/upup/pkg/fi/cloudup/template_functions.go b/upup/pkg/fi/cloudup/template_functions.go index a616a44ab9..88e87f0ea7 100644 --- a/upup/pkg/fi/cloudup/template_functions.go +++ b/upup/pkg/fi/cloudup/template_functions.go @@ -354,6 +354,8 @@ func (tf *TemplateFunctions) CloudControllerConfigArgv() ([]string, error) { argv = append(argv, fmt.Sprintf("--use-service-account-credentials=%t", true)) } + argv = append(argv, "--cloud-config=/etc/kubernetes/cloud.config") + return argv, nil } diff --git a/upup/pkg/fi/cloudup/template_functions_test.go b/upup/pkg/fi/cloudup/template_functions_test.go index 4a97f90299..9580ed34c9 100644 --- a/upup/pkg/fi/cloudup/template_functions_test.go +++ b/upup/pkg/fi/cloudup/template_functions_test.go @@ -42,6 +42,7 @@ func Test_TemplateFunctions_CloudControllerConfigArgv(t *testing.T) { "--v=2", "--cloud-provider=openstack", "--use-service-account-credentials=true", + "--cloud-config=/etc/kubernetes/cloud.config", }, }, { @@ -58,6 +59,7 @@ func Test_TemplateFunctions_CloudControllerConfigArgv(t *testing.T) { "--v=3", "--cloud-provider=openstack", "--use-service-account-credentials=true", + "--cloud-config=/etc/kubernetes/cloud.config", }, }, { @@ -74,6 +76,7 @@ func Test_TemplateFunctions_CloudControllerConfigArgv(t *testing.T) { "--v=3", "--cloud-provider=openstack", "--use-service-account-credentials=true", + "--cloud-config=/etc/kubernetes/cloud.config", }, }, { @@ -100,6 +103,7 @@ func Test_TemplateFunctions_CloudControllerConfigArgv(t *testing.T) { "--cloud-provider=openstack", "--cluster-name=k8s", "--use-service-account-credentials=true", + "--cloud-config=/etc/kubernetes/cloud.config", }, }, { @@ -115,6 +119,7 @@ func Test_TemplateFunctions_CloudControllerConfigArgv(t *testing.T) { "--v=2", "--cloud-provider=openstack", "--use-service-account-credentials=true", + "--cloud-config=/etc/kubernetes/cloud.config", }, }, { @@ -130,6 +135,7 @@ func Test_TemplateFunctions_CloudControllerConfigArgv(t *testing.T) { "--cloud-provider=openstack", "--cluster-cidr=10.0.0.0/24", "--use-service-account-credentials=true", + "--cloud-config=/etc/kubernetes/cloud.config", }, }, { @@ -145,6 +151,7 @@ func Test_TemplateFunctions_CloudControllerConfigArgv(t *testing.T) { "--cloud-provider=openstack", "--allocate-node-cidrs=true", "--use-service-account-credentials=true", + "--cloud-config=/etc/kubernetes/cloud.config", }, }, { @@ -160,6 +167,7 @@ func Test_TemplateFunctions_CloudControllerConfigArgv(t *testing.T) { "--cloud-provider=openstack", "--configure-cloud-routes=true", "--use-service-account-credentials=true", + "--cloud-config=/etc/kubernetes/cloud.config", }, }, { @@ -175,6 +183,7 @@ func Test_TemplateFunctions_CloudControllerConfigArgv(t *testing.T) { "--cloud-provider=openstack", "--cidr-allocator-type=RangeAllocator", "--use-service-account-credentials=true", + "--cloud-config=/etc/kubernetes/cloud.config", }, }, { @@ -189,6 +198,7 @@ func Test_TemplateFunctions_CloudControllerConfigArgv(t *testing.T) { "--v=2", "--cloud-provider=openstack", "--use-service-account-credentials=false", + "--cloud-config=/etc/kubernetes/cloud.config", }, }, } diff --git a/upup/pkg/fi/cloudup/tests/bootstrapchannelbuilder/awscloudcontroller/aws-cloud-controller.addons.k8s.io-k8s-1.18.yaml b/upup/pkg/fi/cloudup/tests/bootstrapchannelbuilder/awscloudcontroller/aws-cloud-controller.addons.k8s.io-k8s-1.18.yaml index b9eb7c366f..d325421f13 100644 --- a/upup/pkg/fi/cloudup/tests/bootstrapchannelbuilder/awscloudcontroller/aws-cloud-controller.addons.k8s.io-k8s-1.18.yaml +++ b/upup/pkg/fi/cloudup/tests/bootstrapchannelbuilder/awscloudcontroller/aws-cloud-controller.addons.k8s.io-k8s-1.18.yaml @@ -27,6 +27,7 @@ spec: - --allocate-node-cidrs=true - --configure-cloud-routes=false - --use-service-account-credentials=true + - --cloud-config=/etc/kubernetes/cloud.config env: - name: KUBERNETES_SERVICE_HOST value: 127.0.0.1 @@ -36,6 +37,10 @@ spec: resources: requests: cpu: 200m + volumeMounts: + - mountPath: /etc/kubernetes/cloud.config + name: cloudconfig + readOnly: true hostNetwork: true nodeSelector: node-role.kubernetes.io/master: "" @@ -47,6 +52,11 @@ spec: value: "true" - effect: NoSchedule key: node-role.kubernetes.io/master + volumes: + - hostPath: + path: /etc/kubernetes/cloud.config + type: "" + name: cloudconfig updateStrategy: type: RollingUpdate diff --git a/upup/pkg/fi/cloudup/tests/bootstrapchannelbuilder/awscloudcontroller/manifest.yaml b/upup/pkg/fi/cloudup/tests/bootstrapchannelbuilder/awscloudcontroller/manifest.yaml index 0e25558928..81641d407a 100644 --- a/upup/pkg/fi/cloudup/tests/bootstrapchannelbuilder/awscloudcontroller/manifest.yaml +++ b/upup/pkg/fi/cloudup/tests/bootstrapchannelbuilder/awscloudcontroller/manifest.yaml @@ -47,7 +47,7 @@ spec: k8s-addon: storage-aws.addons.k8s.io - id: k8s-1.18 manifest: aws-cloud-controller.addons.k8s.io/k8s-1.18.yaml - manifestHash: c2b208761561c8596a3cb60ada550760756f85d1973a55510ce0df044c0f680d + manifestHash: 3928bc84d82fc372a0f5279d4cddbf2d59df6dd0c78460ac5ca7e446872fb42b name: aws-cloud-controller.addons.k8s.io selector: k8s-addon: aws-cloud-controller.addons.k8s.io