Skip to content

Commit 106e7c3

Browse files
authored
feat: additionalTags handlers for AWS and EKS (#1333)
**What problem does this PR solve?**: Add support to set `additionalTags` at both the global level and for individual nodepools. **Which issue(s) this PR fixes**: Fixes # **How Has This Been Tested?**: <!-- Please describe the tests that you ran to verify your changes. Provide output from the tests and any manual steps needed to replicate the tests. --> Added unit tests. Also tested in an EKS cluster with ``` variables: - name: clusterConfig value: eks: additionalTags: Team: nkp IsItOverridable: "no" name: md-0 ... workers: machineDeployments: - class: default-worker variables: overrides: - name: workerConfig value: eks: instanceType: m5.2xlarge additionalTags: NodeType: worker IsItOverridable: "yes" ``` See tags added to the VPC and all other resources being created: <img width="329" height="253" alt="Screenshot 2025-09-30 at 4 59 40 PM" src="https://github.com/user-attachments/assets/58f474ae-685b-4908-b595-c5d2e6991b57" /> See tags added to the instances, notice how the `IsItOverridable` tag comes from the higher precedence `workerConfig` <img width="484" height="362" alt="Screenshot 2025-09-30 at 5 00 18 PM" src="https://github.com/user-attachments/assets/09c9bcc5-9705-4d14-b922-025a167ce5e1" /> **Special notes for your reviewer**: <!-- Use this to provide any additional information to the reviewers. This may include: - Best way to review the PR. - Where the author wants the most review attention on. - etc. -->
1 parent 5cfe9ea commit 106e7c3

26 files changed

+1433
-0
lines changed

api/v1alpha1/aws_clusterconfig_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ import (
88
)
99

1010
type AWSSpec struct {
11+
// AdditionalTags is an optional set of tags to add to an instance,
12+
// in addition to the ones added by default by the AWS provider.
13+
// +optional
14+
AdditionalTags capav1.Tags `json:"additionalTags,omitempty"`
15+
1116
// IdentityRef is a reference to an identity to be used when reconciling the managed control plane.
1217
// If no identity is specified, the default identity for this controller will be used.
1318
// +kubebuilder:validation:Optional

api/v1alpha1/aws_node_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ type AWSWorkerNodeSpec struct {
4343
}
4444

4545
type AWSGenericNodeSpec struct {
46+
// AdditionalTags is an optional set of tags to add to an instance,
47+
// in addition to the ones added by default by the AWS provider.
48+
// +optional
49+
AdditionalTags capav1.Tags `json:"additionalTags,omitempty"`
50+
4651
// AMI or AMI Lookup arguments for machine image of a AWS machine.
4752
// If both AMI ID and AMI lookup arguments are provided then AMI ID takes precedence
4853
// +kubebuilder:validation:Optional

api/v1alpha1/crds/caren.nutanix.com_awsclusterconfigs.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,13 @@ spec:
290290
aws:
291291
description: AWS cluster configuration.
292292
properties:
293+
additionalTags:
294+
additionalProperties:
295+
type: string
296+
description: |-
297+
AdditionalTags is an optional set of tags to add to an instance,
298+
in addition to the ones added by default by the AWS provider.
299+
type: object
293300
controlPlaneLoadBalancer:
294301
description: AWSLoadBalancerSpec configures an AWS control-plane LoadBalancer.
295302
properties:
@@ -388,6 +395,13 @@ spec:
388395
type: object
389396
maxItems: 32
390397
type: array
398+
additionalTags:
399+
additionalProperties:
400+
type: string
401+
description: |-
402+
AdditionalTags is an optional set of tags to add to an instance,
403+
in addition to the ones added by default by the AWS provider.
404+
type: object
391405
ami:
392406
description: |-
393407
AMI or AMI Lookup arguments for machine image of a AWS machine.

api/v1alpha1/crds/caren.nutanix.com_awsworkernodeconfigs.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ spec:
5757
type: object
5858
maxItems: 32
5959
type: array
60+
additionalTags:
61+
additionalProperties:
62+
type: string
63+
description: |-
64+
AdditionalTags is an optional set of tags to add to an instance,
65+
in addition to the ones added by default by the AWS provider.
66+
type: object
6067
ami:
6168
description: |-
6269
AMI or AMI Lookup arguments for machine image of a AWS machine.

api/v1alpha1/crds/caren.nutanix.com_eksclusterconfigs.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,13 @@ spec:
292292
eks:
293293
description: EKS cluster configuration.
294294
properties:
295+
additionalTags:
296+
additionalProperties:
297+
type: string
298+
description: |-
299+
AdditionalTags is an optional set of tags to add to an instance,
300+
in addition to the ones added by default by the AWS provider.
301+
type: object
295302
identityRef:
296303
description: |-
297304
IdentityRef is a reference to an identity to be used when reconciling the managed control plane.

api/v1alpha1/crds/caren.nutanix.com_eksworkernodeconfigs.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ spec:
5757
type: object
5858
maxItems: 32
5959
type: array
60+
additionalTags:
61+
additionalProperties:
62+
type: string
63+
description: |-
64+
AdditionalTags is an optional set of tags to add to an instance,
65+
in addition to the ones added by default by the AWS provider.
66+
type: object
6067
ami:
6168
description: |-
6269
AMI or AMI Lookup arguments for machine image of a AWS machine.

api/v1alpha1/eks_clusterconfig_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ import (
88
)
99

1010
type EKSSpec struct {
11+
// AdditionalTags is an optional set of tags to add to an instance,
12+
// in addition to the ones added by default by the AWS provider.
13+
// +optional
14+
AdditionalTags capav1.Tags `json:"additionalTags,omitempty"`
15+
1116
// IdentityRef is a reference to an identity to be used when reconciling the managed control plane.
1217
// If no identity is specified, the default identity for this controller will be used.
1318
// +kubebuilder:validation:Optional

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
+++
2+
title = "AWS Additional Tags"
3+
+++
4+
5+
The AWS additional tags customization allows the user to specify custom tags to be applied to AWS resources created by the cluster.
6+
The customization can be applied at the cluster level, control plane level, and worker node level.
7+
This customization will be available when the
8+
[provider-specific cluster configuration patch]({{< ref "..">}}) is included in the `ClusterClass`.
9+
10+
## Example
11+
12+
To specify additional tags for all AWS resources, use the following configuration:
13+
14+
```yaml
15+
apiVersion: cluster.x-k8s.io/v1beta1
16+
kind: Cluster
17+
metadata:
18+
name: <NAME>
19+
spec:
20+
topology:
21+
variables:
22+
- name: clusterConfig
23+
value:
24+
aws:
25+
additionalTags:
26+
Environment: production
27+
Team: platform
28+
CostCenter: "12345"
29+
controlPlane:
30+
aws:
31+
additionalTags:
32+
NodeType: control-plane
33+
- name: workerConfig
34+
value:
35+
aws:
36+
additionalTags:
37+
NodeType: worker
38+
Workload: general
39+
```
40+
41+
We can further customize individual MachineDeployments by using the overrides field with the following configuration:
42+
43+
```yaml
44+
spec:
45+
topology:
46+
# ...
47+
workers:
48+
machineDeployments:
49+
- class: default-worker
50+
name: md-0
51+
variables:
52+
overrides:
53+
- name: workerConfig
54+
value:
55+
aws:
56+
additionalTags:
57+
NodeType: worker
58+
Workload: database
59+
Environment: production
60+
```
61+
62+
## Tag Precedence
63+
64+
When tags are specified at multiple levels, the following precedence applies (higher precedence overrides lower):
65+
66+
1. **Worker level tags** and **Control plane level tags** (highest precedence)
67+
1. **Cluster level tags** (lowest precedence)
68+
69+
This means that if the same tag key is specified at multiple levels, the worker and contorl-plane level values will take precedence over the cluster level values.
70+
71+
## Applying this configuration will result in the following values being set
72+
73+
- `AWSCluster`:
74+
75+
- ```yaml
76+
spec:
77+
template:
78+
spec:
79+
additionalTags:
80+
Environment: production
81+
Team: platform
82+
CostCenter: "12345"
83+
```
84+
85+
- control-plane `AWSMachineTemplate`:
86+
87+
- ```yaml
88+
spec:
89+
template:
90+
spec:
91+
additionalTags:
92+
Environment: production
93+
Team: platform
94+
CostCenter: "12345"
95+
NodeType: control-plane
96+
```
97+
98+
- worker `AWSMachineTemplate`:
99+
100+
- ```yaml
101+
spec:
102+
template:
103+
spec:
104+
additionalTags:
105+
Environment: production
106+
Team: platform
107+
CostCenter: "12345"
108+
NodeType: worker
109+
Workload: general
110+
```
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
+++
2+
title = "EKS Additional Tags"
3+
+++
4+
5+
The EKS additional tags customization allows the user to specify custom tags to be applied to AWS resources created by the EKS cluster.
6+
The customization can be applied at the cluster level and worker node level.
7+
This customization will be available when the
8+
[provider-specific cluster configuration patch]({{< ref "..">}}) is included in the `ClusterClass`.
9+
10+
## Example
11+
12+
To specify additional tags for EKS resources, use the following configuration:
13+
14+
```yaml
15+
apiVersion: cluster.x-k8s.io/v1beta1
16+
kind: Cluster
17+
metadata:
18+
name: <NAME>
19+
spec:
20+
topology:
21+
variables:
22+
- name: clusterConfig
23+
value:
24+
eks:
25+
additionalTags:
26+
Environment: production
27+
Team: platform
28+
CostCenter: "12345"
29+
```
30+
31+
We can further customize individual MachineDeployments by using the overrides field with the following configuration:
32+
33+
```yaml
34+
spec:
35+
topology:
36+
# ...
37+
workers:
38+
machineDeployments:
39+
- class: default-worker
40+
name: md-0
41+
variables:
42+
overrides:
43+
- name: workerConfig
44+
value:
45+
eks:
46+
additionalTags:
47+
NodeType: worker
48+
Workload: database
49+
Environment: production
50+
```
51+
52+
## Tag Precedence
53+
54+
When tags are specified at multiple levels, the following precedence applies (higher precedence overrides lower):
55+
56+
1. **Worker level tags** (highest precedence)
57+
2. **Cluster level tags** (lowest precedence)
58+
59+
This means that if the same tag key is specified at multiple levels, the worker level values will take precedence over the cluster level values.
60+
61+
## Applying this configuration will result in the following values being set
62+
63+
- `AWSManagedControlPlane`:
64+
65+
- ```yaml
66+
spec:
67+
template:
68+
spec:
69+
additionalTags:
70+
Environment: production
71+
Team: platform
72+
CostCenter: "12345"
73+
```
74+
75+
- worker `AWSMachineTemplate`:
76+
77+
- ```yaml
78+
spec:
79+
template:
80+
spec:
81+
additionalTags:
82+
Environment: production
83+
Team: platform
84+
CostCenter: "12345"
85+
NodeType: worker
86+
Workload: general
87+
```

0 commit comments

Comments
 (0)