Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated cherry pick of #17141: Only set NTH ManagedASGTag label if it doesn't already exist #17143

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pkg/model/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ func (b *KopsModelContext) CloudTagsForInstanceGroup(ig *kops.InstanceGroup) (ma
// Apply NTH Labels
nth := b.Cluster.Spec.CloudProvider.AWS.NodeTerminationHandler
if nth.IsQueueMode() {
labels[fi.ValueOf(nth.ManagedASGTag)] = ""
k := fi.ValueOf(nth.ManagedASGTag)
if _, ok := labels[k]; !ok && k != "" {
labels[k] = ""
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ spec:
enableSpotInterruptionDraining: true
enabled: true
excludeFromLoadBalancers: true
managedASGTag: aws-node-termination-handler/managed
managedASGTag: kubernetes.io/cluster/complex.example.com
memoryRequest: 64Mi
podTerminationGracePeriod: -1
prometheusEnable: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ spec:
version: 9.99.0
- id: k8s-1.11
manifest: node-termination-handler.aws/k8s-1.11.yaml
manifestHash: 93627ba43aa9bca83bd85005d328f2b42c28a9cf0cad1c03375fa4e33d59a877
manifestHash: 565c78752a2216a5bef8c63aff4fe1435e054689f565f587b375c593b346a411
name: node-termination-handler.aws
prune:
kinds:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ spec:
- name: CHECK_TAG_BEFORE_DRAINING
value: "true"
- name: MANAGED_TAG
value: aws-node-termination-handler/managed
value: kubernetes.io/cluster/complex.example.com
- name: USE_PROVIDER_ID
value: "true"
- name: DRY_RUN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ spec:
kubernetesVersion: v1.30.0
masterPublicName: api.complex.example.com
networkCIDR: 172.20.0.0/16
nodeTerminationHandler:
managedASGTag: kubernetes.io/cluster/complex.example.com
additionalNetworkCIDRs:
- 10.1.0.0/16
- 10.2.0.0/16
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/update_cluster/complex/in-v1alpha2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ spec:
kubernetesVersion: v1.30.0
masterPublicName: api.complex.example.com
networkCIDR: 172.20.0.0/16
nodeTerminationHandler:
managedASGTag: kubernetes.io/cluster/complex.example.com
additionalNetworkCIDRs:
- 10.1.0.0/16
- 10.2.0.0/16
Expand Down
16 changes: 0 additions & 16 deletions tests/integration/update_cluster/complex/kubernetes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,6 @@ resource "aws_autoscaling_group" "master-us-test-1a-masters-complex-example-com"
propagate_at_launch = true
value = "John Doe"
}
tag {
key = "aws-node-termination-handler/managed"
propagate_at_launch = true
value = ""
}
tag {
key = "foo/bar"
propagate_at_launch = true
Expand Down Expand Up @@ -218,11 +213,6 @@ resource "aws_autoscaling_group" "nodes-complex-example-com" {
propagate_at_launch = true
value = "John Doe"
}
tag {
key = "aws-node-termination-handler/managed"
propagate_at_launch = true
value = ""
}
tag {
key = "foo/bar"
propagate_at_launch = true
Expand Down Expand Up @@ -493,7 +483,6 @@ resource "aws_launch_template" "master-us-test-1a-masters-complex-example-com" {
"KubernetesCluster" = "complex.example.com"
"Name" = "master-us-test-1a.masters.complex.example.com"
"Owner" = "John Doe"
"aws-node-termination-handler/managed" = ""
"foo/bar" = "fib+baz"
"k8s.io/cluster-autoscaler/node-template/label/kops.k8s.io/kops-controller-pki" = ""
"k8s.io/cluster-autoscaler/node-template/label/node-role.kubernetes.io/control-plane" = ""
Expand All @@ -510,7 +499,6 @@ resource "aws_launch_template" "master-us-test-1a-masters-complex-example-com" {
"KubernetesCluster" = "complex.example.com"
"Name" = "master-us-test-1a.masters.complex.example.com"
"Owner" = "John Doe"
"aws-node-termination-handler/managed" = ""
"foo/bar" = "fib+baz"
"k8s.io/cluster-autoscaler/node-template/label/kops.k8s.io/kops-controller-pki" = ""
"k8s.io/cluster-autoscaler/node-template/label/node-role.kubernetes.io/control-plane" = ""
Expand All @@ -525,7 +513,6 @@ resource "aws_launch_template" "master-us-test-1a-masters-complex-example-com" {
"KubernetesCluster" = "complex.example.com"
"Name" = "master-us-test-1a.masters.complex.example.com"
"Owner" = "John Doe"
"aws-node-termination-handler/managed" = ""
"foo/bar" = "fib+baz"
"k8s.io/cluster-autoscaler/node-template/label/kops.k8s.io/kops-controller-pki" = ""
"k8s.io/cluster-autoscaler/node-template/label/node-role.kubernetes.io/control-plane" = ""
Expand Down Expand Up @@ -593,7 +580,6 @@ resource "aws_launch_template" "nodes-complex-example-com" {
"KubernetesCluster" = "complex.example.com"
"Name" = "nodes.complex.example.com"
"Owner" = "John Doe"
"aws-node-termination-handler/managed" = ""
"foo/bar" = "fib+baz"
"k8s.io/cluster-autoscaler/node-template/label/node-role.kubernetes.io/node" = ""
"k8s.io/role/node" = "1"
Expand All @@ -607,7 +593,6 @@ resource "aws_launch_template" "nodes-complex-example-com" {
"KubernetesCluster" = "complex.example.com"
"Name" = "nodes.complex.example.com"
"Owner" = "John Doe"
"aws-node-termination-handler/managed" = ""
"foo/bar" = "fib+baz"
"k8s.io/cluster-autoscaler/node-template/label/node-role.kubernetes.io/node" = ""
"k8s.io/role/node" = "1"
Expand All @@ -619,7 +604,6 @@ resource "aws_launch_template" "nodes-complex-example-com" {
"KubernetesCluster" = "complex.example.com"
"Name" = "nodes.complex.example.com"
"Owner" = "John Doe"
"aws-node-termination-handler/managed" = ""
"foo/bar" = "fib+baz"
"k8s.io/cluster-autoscaler/node-template/label/node-role.kubernetes.io/node" = ""
"k8s.io/role/node" = "1"
Expand Down
Loading