From b2104ab27431a7cc69f61be36c0cfadb7857fdb4 Mon Sep 17 00:00:00 2001 From: Ole Markus With Date: Sun, 19 Dec 2021 08:16:06 +0100 Subject: [PATCH] Bump karpenter to 0.5.3 and RBN support --- pkg/apis/nodeup/config.go | 6 +++++- ...et_object_minimal.example.com-addons-bootstrap_content | 2 +- ...nimal.example.com-addons-karpenter.sh-k8s-1.19_content | 4 ++-- .../resources/addons/karpenter.sh/k8s-1.19.yaml.template | 8 ++++++-- upup/pkg/fi/cloudup/template_functions.go | 5 +++++ 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/pkg/apis/nodeup/config.go b/pkg/apis/nodeup/config.go index 466491c0bb..48a6e7ab4d 100644 --- a/pkg/apis/nodeup/config.go +++ b/pkg/apis/nodeup/config.go @@ -208,13 +208,17 @@ func NewConfig(cluster *kops.Cluster, instanceGroup *kops.InstanceGroup) (*Confi config.DefaultMachineType = fi.String(strings.Split(instanceGroup.Spec.MachineType, ",")[0]) } - if cluster.Spec.ExternalCloudControllerManager != nil && cluster.IsKubernetesGTE("1.23") && cluster.Spec.CloudProvider == string(kops.CloudProviderAWS) { + if UsesInstanceIDForNodeName(cluster) { config.UseInstanceIDForNodeName = true } return &config, &bootConfig } +func UsesInstanceIDForNodeName(cluster *kops.Cluster) bool { + return cluster.Spec.ExternalCloudControllerManager != nil && cluster.IsKubernetesGTE("1.23") && kops.CloudProviderID(cluster.Spec.CloudProvider) == kops.CloudProviderAWS +} + func filterFileAssets(f []kops.FileAssetSpec, role kops.InstanceGroupRole) []kops.FileAssetSpec { var fileAssets []kops.FileAssetSpec for _, fileAsset := range f { diff --git a/tests/integration/update_cluster/karpenter/data/aws_s3_bucket_object_minimal.example.com-addons-bootstrap_content b/tests/integration/update_cluster/karpenter/data/aws_s3_bucket_object_minimal.example.com-addons-bootstrap_content index c25eeebe12..8f0c6a1b91 100644 --- a/tests/integration/update_cluster/karpenter/data/aws_s3_bucket_object_minimal.example.com-addons-bootstrap_content +++ b/tests/integration/update_cluster/karpenter/data/aws_s3_bucket_object_minimal.example.com-addons-bootstrap_content @@ -54,7 +54,7 @@ spec: version: 9.99.0 - id: k8s-1.19 manifest: karpenter.sh/k8s-1.19.yaml - manifestHash: 51f69d18f68a247940eb8eb8b28029341a4ba3a644a7e194be3e6f60d21f9e64 + manifestHash: aa53e65325a4e3d28c9374f8910c0c359880c3654b1612a35f0a626c718cea5b name: karpenter.sh selector: k8s-addon: karpenter.sh diff --git a/tests/integration/update_cluster/karpenter/data/aws_s3_bucket_object_minimal.example.com-addons-karpenter.sh-k8s-1.19_content b/tests/integration/update_cluster/karpenter/data/aws_s3_bucket_object_minimal.example.com-addons-karpenter.sh-k8s-1.19_content index 5df2c8ac5a..974fd0da7c 100644 --- a/tests/integration/update_cluster/karpenter/data/aws_s3_bucket_object_minimal.example.com-addons-karpenter.sh-k8s-1.19_content +++ b/tests/integration/update_cluster/karpenter/data/aws_s3_bucket_object_minimal.example.com-addons-karpenter.sh-k8s-1.19_content @@ -627,7 +627,7 @@ spec: value: arn:aws-test:iam::123456789012:role/karpenter.kube-system.sa.minimal.example.com - name: AWS_WEB_IDENTITY_TOKEN_FILE value: /var/run/secrets/amazonaws.com/token - image: public.ecr.aws/karpenter/controller:v0.5.2 + image: public.ecr.aws/karpenter/controller:v0.5.3 livenessProbe: httpGet: path: /healthz @@ -720,7 +720,7 @@ spec: value: arn:aws-test:iam::123456789012:role/karpenter.kube-system.sa.minimal.example.com - name: AWS_WEB_IDENTITY_TOKEN_FILE value: /var/run/secrets/amazonaws.com/token - image: public.ecr.aws/karpenter/webhook:v0.5.2 + image: public.ecr.aws/karpenter/webhook:v0.5.3 livenessProbe: httpGet: port: 8443 diff --git a/upup/models/cloudup/resources/addons/karpenter.sh/k8s-1.19.yaml.template b/upup/models/cloudup/resources/addons/karpenter.sh/k8s-1.19.yaml.template index 7579ef7c52..e9769e4e8d 100644 --- a/upup/models/cloudup/resources/addons/karpenter.sh/k8s-1.19.yaml.template +++ b/upup/models/cloudup/resources/addons/karpenter.sh/k8s-1.19.yaml.template @@ -441,7 +441,7 @@ spec: serviceAccountName: karpenter containers: - name: manager - image: public.ecr.aws/karpenter/controller:v0.5.2 + image: public.ecr.aws/karpenter/controller:v0.5.3 resources: limits: cpu: 1 @@ -463,6 +463,10 @@ spec: path: /readyz port: 8081 env: + {{ if UsesInstanceIDForNodeName }} + - name: AWS_NODE_NAME_CONVENTION + value: "resouce-name" + {{ end }} - name: AWS_REGION value: {{ Region }} - name: CLUSTER_NAME @@ -507,7 +511,7 @@ spec: serviceAccountName: karpenter containers: - name: webhook - image: public.ecr.aws/karpenter/webhook:v0.5.2 + image: public.ecr.aws/karpenter/webhook:v0.5.3 args: - -port=8443 resources: diff --git a/upup/pkg/fi/cloudup/template_functions.go b/upup/pkg/fi/cloudup/template_functions.go index b26d0e3c8d..181aca821f 100644 --- a/upup/pkg/fi/cloudup/template_functions.go +++ b/upup/pkg/fi/cloudup/template_functions.go @@ -49,6 +49,7 @@ import ( "k8s.io/kops/pkg/apis/kops" apiModel "k8s.io/kops/pkg/apis/kops/model" "k8s.io/kops/pkg/apis/kops/util" + "k8s.io/kops/pkg/apis/nodeup" "k8s.io/kops/pkg/dns" "k8s.io/kops/pkg/featureflag" "k8s.io/kops/pkg/kubemanifest" @@ -285,6 +286,10 @@ func (tf *TemplateFunctions) AddTo(dest template.FuncMap, secretStore fi.SecretS dest["ParseTaint"] = parseTaint + dest["UsesInstanceIDForNodeName"] = func() bool { + return nodeup.UsesInstanceIDForNodeName(tf.Cluster) + } + return nil }