Skip to content

Commit dccde99

Browse files
authored
Merge pull request #8915 from zalando-incubator/register-with-taints-kubelet-config
Move registerWithTaint to userdata.yaml
2 parents c8e55ed + 9ef47e9 commit dccde99

File tree

7 files changed

+50
-15
lines changed

7 files changed

+50
-15
lines changed

cluster/config-defaults.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -756,12 +756,14 @@ tracing_coredns_local_zone_traces_endpoint: ""
756756
# AMI id given the image name and the Image AWS account owner.
757757
#
758758
# [0]: https://github.com/zalando-incubator/cluster-lifecycle-manager/blob/8a9bd1cb2d094038a9e23e646421f8146b48886a/provisioner/template.go#L116
759-
kuberuntu_image_v1_31_jammy_amd64: {{ amiID "zalando-ubuntu-jammy-22.04-kubernetes-production-v1.31.4-amd64-master-359" "861068367966" }}
760-
kuberuntu_image_v1_31_jammy_arm64: {{ amiID "zalando-ubuntu-jammy-22.04-kubernetes-production-v1.31.4-arm64-master-359" "861068367966" }}
761-
762-
# Which distro from the previous config items should be used. Valid options are only `jammy` for now. Can be set for each node pool.
763-
kuberuntu_distro_master: "jammy"
764-
kuberuntu_distro_worker: "jammy"
759+
kuberuntu_image_v1_31_old_amd64: {{ amiID "zalando-ubuntu-jammy-22.04-kubernetes-production-v1.31.4-amd64-master-359" "861068367966" }}
760+
kuberuntu_image_v1_31_old_arm64: {{ amiID "zalando-ubuntu-jammy-22.04-kubernetes-production-v1.31.4-arm64-master-359" "861068367966" }}
761+
kuberuntu_image_v1_31_new_amd64: {{ amiID "zalando-ubuntu-jammy-22.04-kubernetes-production-v1.31.6-amd64-master-368" "861068367966" }}
762+
kuberuntu_image_v1_31_new_arm64: {{ amiID "zalando-ubuntu-jammy-22.04-kubernetes-production-v1.31.6-arm64-master-368" "861068367966" }}
763+
764+
# This is used to determine which AMI to use for the cluster or individual node
765+
# pools. Possible values are 'new' or 'old'
766+
kuberuntu_ami_version: "new"
765767

766768
# Feature toggle for auditing events
767769
audit_pod_events: "true"

cluster/node-pools/master-default/stack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Mappings:
1010
Images:
1111
{{.Cluster.Region}}:
1212
# Use the node pool's architecture to construct the config item name that we're using to get the AMI name.
13-
MachineImage: '{{ index .NodePool.ConfigItems (print "kuberuntu_image_v1_31_" .NodePool.ConfigItems.kuberuntu_distro_master "_" .Values.InstanceInfo.Architecture) }}'
13+
MachineImage: '{{ index .NodePool.ConfigItems (print "kuberuntu_image_v1_31_" .NodePool.ConfigItems.kuberuntu_ami_version "_" .Values.InstanceInfo.Architecture) }}'
1414

1515
Resources:
1616
AutoScalingGroup:

cluster/node-pools/master-default/userdata.yaml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ write_files:
33
- owner: root:root
44
path: /etc/kubernetes/secrets.env
55
content: |
6+
{{- if eq .NodePool.ConfigItems.kuberuntu_ami_version "old" }}
67
NODEPOOL_TAINTS=node.kubernetes.io/role=master:NoSchedule{{if index .NodePool.ConfigItems "taints"}},{{.NodePool.ConfigItems.taints}}{{end}}
8+
{{- end }}
79
NODE_LABELS=master=true,node.kubernetes.io/exclude-from-external-load-balancers,node.kubernetes.io/distro=ubuntu,cluster-lifecycle-controller.zalan.do/decommission-priority=999,lifecycle-status=ready{{if index .NodePool.ConfigItems "labels"}},{{.NodePool.ConfigItems.labels}}{{end}}
810
NODEPOOL_NAME={{ .NodePool.Name }}
911
KUBELET_ROLE=master
@@ -76,6 +78,19 @@ write_files:
7678
# variables are replaced on instance start-up.
7779
providerID: __PROVIDER_ID__
7880
clusterDNS: [__CLUSTER_DNS__]
81+
{{- if eq .NodePool.ConfigItems.kuberuntu_ami_version "new" }}
82+
registerWithTaints:
83+
- key: node.kubernetes.io/role
84+
value: master
85+
effect: NoSchedule
86+
{{- range $taint := .NodePool.Taints }}
87+
- key: {{$taint.Key}}
88+
effect: {{$taint.Effect}}
89+
{{- if $taint.Value }}
90+
value: {{$taint.Value }}
91+
{{- end }}
92+
{{- end }}
93+
{{- end }}
7994

8095
- owner: root:root
8196
path: /etc/kubernetes/manifests/kube-apiserver.yaml
@@ -923,7 +938,7 @@ write_files:
923938
{{index $cfg 0}} = {{index $cfg 1}}
924939
{{- end}}
925940
{{- end}}
926-
941+
{{ if eq .NodePool.ConfigItems.kuberuntu_ami_version "old" }}
927942
# TODO: Remove this once all nodes are running an AMI compatible with /etc/cni/net.d/10-flannel.conflist
928943
- owner: root:root
929944
path: /etc/kubernetes/cni/net.d/10-flannel.conflist
@@ -941,7 +956,7 @@ write_files:
941956
}
942957
]
943958
}
944-
959+
{{ end }}
945960
- owner: root:root
946961
path: /etc/cni/net.d/10-flannel.conflist
947962
content: |

cluster/node-pools/worker-combined/stack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Mappings:
1010
Images:
1111
{{.Cluster.Region}}:
1212
# Use the node pool's architecture to construct the config item name that we're using to get the AMI name.
13-
MachineImage: '{{ index .NodePool.ConfigItems (print "kuberuntu_image_v1_31_" .NodePool.ConfigItems.kuberuntu_distro_worker "_" .Values.InstanceInfo.Architecture) }}'
13+
MachineImage: '{{ index .NodePool.ConfigItems (print "kuberuntu_image_v1_31_" .NodePool.ConfigItems.kuberuntu_ami_version "_" .Values.InstanceInfo.Architecture) }}'
1414

1515
Resources:
1616
AutoScalingGroup:

cluster/node-pools/worker-karpenter/provisioners.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ spec:
88
amiFamily: Custom
99
amiSelectorTerms:
1010
# Select on any AMI that has any of the following IDs
11-
- id: {{ index .NodePool.ConfigItems (print "kuberuntu_image_v1_31_" .NodePool.ConfigItems.kuberuntu_distro_worker "_amd64") }}
12-
- id: {{ index .NodePool.ConfigItems (print "kuberuntu_image_v1_31_" .NodePool.ConfigItems.kuberuntu_distro_worker "_arm64") }}
11+
- id: {{ index .NodePool.ConfigItems (print "kuberuntu_image_v1_31_" .NodePool.ConfigItems.kuberuntu_ami_version "_amd64") }}
12+
- id: {{ index .NodePool.ConfigItems (print "kuberuntu_image_v1_31_" .NodePool.ConfigItems.kuberuntu_ami_version "_arm64") }}
1313
metadataOptions:
1414
httpEndpoint: enabled
1515
httpProtocolIPv6: disabled

cluster/node-pools/worker-splitaz/stack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Mappings:
1010
Images:
1111
{{.Cluster.Region}}:
1212
# Use the node pool's architecture to construct the config item name that we're using to get the AMI name.
13-
MachineImage: '{{ index .NodePool.ConfigItems (print "kuberuntu_image_v1_31_" .NodePool.ConfigItems.kuberuntu_distro_worker "_" .Values.InstanceInfo.Architecture) }}'
13+
MachineImage: '{{ index .NodePool.ConfigItems (print "kuberuntu_image_v1_31_" .NodePool.ConfigItems.kuberuntu_ami_version "_" .Values.InstanceInfo.Architecture) }}'
1414

1515
Resources:
1616
{{ with $data := . }}

cluster/node-pools/worker-splitaz/userdata.yaml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ write_files:
77
- owner: root:root
88
path: /etc/kubernetes/secrets.env
99
content: |
10+
{{- if eq .NodePool.ConfigItems.kuberuntu_ami_version "old" }}
1011
NODEPOOL_TAINTS={{if index .NodePool.ConfigItems "taints"}}{{.NodePool.ConfigItems.taints}}{{end}}
12+
{{- end }}
1113
NODE_LABELS=node.kubernetes.io/profile={{ .NodePool.Profile }},lifecycle-status=ready,node.kubernetes.io/distro=ubuntu{{if index .NodePool.ConfigItems "labels"}},{{.NodePool.ConfigItems.labels}}{{end}}{{if or (eq .NodePool.Profile "worker-splitaz") (eq .NodePool.Profile "worker-combined")}},asg-lifecycle-hook=true{{end}}
1214
NODEPOOL_NAME={{ .NodePool.Name }}
1315
KUBELET_ROLE=worker
@@ -118,6 +120,22 @@ write_files:
118120
# variables are replaced on instance start-up.
119121
providerID: __PROVIDER_ID__
120122
clusterDNS: [__CLUSTER_DNS__]
123+
{{- if eq .NodePool.ConfigItems.kuberuntu_ami_version "new" }}
124+
{{- if or (.NodePool.Taints) (eq .NodePool.Profile "worker-karpenter") }}
125+
registerWithTaints:
126+
{{- range $taint := .NodePool.Taints }}
127+
- key: {{$taint.Key}}
128+
effect: {{$taint.Effect}}
129+
{{- if $taint.Value }}
130+
value: {{$taint.Value }}
131+
{{- end }}
132+
{{- end }}
133+
{{- if eq .NodePool.Profile "worker-karpenter" }}
134+
- key: karpenter.sh/unregistered
135+
effect: NoExecute
136+
{{- end }}
137+
{{- end }}
138+
{{- end }}
121139

122140
{{- if and .Cluster.ConfigItems.vm_dirty_background_bytes .Cluster.ConfigItems.vm_dirty_bytes }}
123141
- owner: root:root
@@ -135,7 +153,7 @@ write_files:
135153
{{index $cfg 0}} = {{index $cfg 1}}
136154
{{- end}}
137155
{{- end}}
138-
156+
{{ if eq .NodePool.ConfigItems.kuberuntu_ami_version "old" }}
139157
# TODO: Remove this once all nodes are running an AMI compatible with /etc/cni/net.d/10-flannel.conflist
140158
- owner: root:root
141159
path: /etc/kubernetes/cni/net.d/10-flannel.conflist
@@ -153,7 +171,7 @@ write_files:
153171
}
154172
]
155173
}
156-
174+
{{ end }}
157175
- owner: root:root
158176
path: /etc/cni/net.d/10-flannel.conflist
159177
content: |

0 commit comments

Comments
 (0)