Skip to content

Commit

Permalink
Merge pull request #17141 from rifelpet/nth-asg-tag
Browse files Browse the repository at this point in the history
Only set NTH ManagedASGTag label if it doesn't already exist
  • Loading branch information
k8s-ci-robot authored Dec 17, 2024
2 parents d7fd342 + 4c5ee60 commit 011ab0f
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 20 deletions.
5 changes: 4 additions & 1 deletion pkg/model/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,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

0 comments on commit 011ab0f

Please sign in to comment.