Skip to content
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: 5 additions & 0 deletions api/v1alpha1/aws_clusterconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import (
)

type AWSSpec struct {
// AdditionalTags is an optional set of tags to add to an instance,
// in addition to the ones added by default by the AWS provider.
// +optional
AdditionalTags capav1.Tags `json:"additionalTags,omitempty"`

// IdentityRef is a reference to an identity to be used when reconciling the managed control plane.
// If no identity is specified, the default identity for this controller will be used.
// +kubebuilder:validation:Optional
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/aws_node_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ type AWSWorkerNodeSpec struct {
}

type AWSGenericNodeSpec struct {
// AdditionalTags is an optional set of tags to add to an instance,
// in addition to the ones added by default by the AWS provider.
// +optional
AdditionalTags capav1.Tags `json:"additionalTags,omitempty"`

// AMI or AMI Lookup arguments for machine image of a AWS machine.
// If both AMI ID and AMI lookup arguments are provided then AMI ID takes precedence
// +kubebuilder:validation:Optional
Expand Down
14 changes: 14 additions & 0 deletions api/v1alpha1/crds/caren.nutanix.com_awsclusterconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,13 @@ spec:
aws:
description: AWS cluster configuration.
properties:
additionalTags:
additionalProperties:
type: string
description: |-
AdditionalTags is an optional set of tags to add to an instance,
in addition to the ones added by default by the AWS provider.
type: object
controlPlaneLoadBalancer:
description: AWSLoadBalancerSpec configures an AWS control-plane LoadBalancer.
properties:
Expand Down Expand Up @@ -388,6 +395,13 @@ spec:
type: object
maxItems: 32
type: array
additionalTags:
additionalProperties:
type: string
description: |-
AdditionalTags is an optional set of tags to add to an instance,
in addition to the ones added by default by the AWS provider.
type: object
ami:
description: |-
AMI or AMI Lookup arguments for machine image of a AWS machine.
Expand Down
7 changes: 7 additions & 0 deletions api/v1alpha1/crds/caren.nutanix.com_awsworkernodeconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ spec:
type: object
maxItems: 32
type: array
additionalTags:
additionalProperties:
type: string
description: |-
AdditionalTags is an optional set of tags to add to an instance,
in addition to the ones added by default by the AWS provider.
type: object
ami:
description: |-
AMI or AMI Lookup arguments for machine image of a AWS machine.
Expand Down
7 changes: 7 additions & 0 deletions api/v1alpha1/crds/caren.nutanix.com_eksclusterconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,13 @@ spec:
eks:
description: EKS cluster configuration.
properties:
additionalTags:
additionalProperties:
type: string
description: |-
AdditionalTags is an optional set of tags to add to an instance,
in addition to the ones added by default by the AWS provider.
type: object
identityRef:
description: |-
IdentityRef is a reference to an identity to be used when reconciling the managed control plane.
Expand Down
7 changes: 7 additions & 0 deletions api/v1alpha1/crds/caren.nutanix.com_eksworkernodeconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ spec:
type: object
maxItems: 32
type: array
additionalTags:
additionalProperties:
type: string
description: |-
AdditionalTags is an optional set of tags to add to an instance,
in addition to the ones added by default by the AWS provider.
type: object
ami:
description: |-
AMI or AMI Lookup arguments for machine image of a AWS machine.
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/eks_clusterconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import (
)

type EKSSpec struct {
// AdditionalTags is an optional set of tags to add to an instance,
// in addition to the ones added by default by the AWS provider.
// +optional
AdditionalTags capav1.Tags `json:"additionalTags,omitempty"`

// IdentityRef is a reference to an identity to be used when reconciling the managed control plane.
// If no identity is specified, the default identity for this controller will be used.
// +kubebuilder:validation:Optional
Expand Down
21 changes: 21 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

110 changes: 110 additions & 0 deletions docs/content/customization/aws/tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
+++
title = "AWS Additional Tags"
+++

The AWS additional tags customization allows the user to specify custom tags to be applied to AWS resources created by the cluster.
The customization can be applied at the cluster level, control plane level, and worker node level.
This customization will be available when the
[provider-specific cluster configuration patch]({{< ref "..">}}) is included in the `ClusterClass`.

## Example

To specify additional tags for all AWS resources, use the following configuration:

```yaml
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
name: <NAME>
spec:
topology:
variables:
- name: clusterConfig
value:
aws:
additionalTags:
Environment: production
Team: platform
CostCenter: "12345"
controlPlane:
aws:
additionalTags:
NodeType: control-plane
- name: workerConfig
value:
aws:
additionalTags:
NodeType: worker
Workload: general
```

We can further customize individual MachineDeployments by using the overrides field with the following configuration:

```yaml
spec:
topology:
# ...
workers:
machineDeployments:
- class: default-worker
name: md-0
variables:
overrides:
- name: workerConfig
value:
aws:
additionalTags:
NodeType: worker
Workload: database
Environment: production
```

## Tag Precedence

When tags are specified at multiple levels, the following precedence applies (higher precedence overrides lower):

1. **Worker level tags** and **Control plane level tags** (highest precedence)
1. **Cluster level tags** (lowest precedence)

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.

## Applying this configuration will result in the following values being set

- `AWSCluster`:

- ```yaml
spec:
template:
spec:
additionalTags:
Environment: production
Team: platform
CostCenter: "12345"
```

- control-plane `AWSMachineTemplate`:

- ```yaml
spec:
template:
spec:
additionalTags:
Environment: production
Team: platform
CostCenter: "12345"
NodeType: control-plane
```

- worker `AWSMachineTemplate`:

- ```yaml
spec:
template:
spec:
additionalTags:
Environment: production
Team: platform
CostCenter: "12345"
NodeType: worker
Workload: general
```
87 changes: 87 additions & 0 deletions docs/content/customization/eks/tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
+++
title = "EKS Additional Tags"
+++

The EKS additional tags customization allows the user to specify custom tags to be applied to AWS resources created by the EKS cluster.
The customization can be applied at the cluster level and worker node level.
This customization will be available when the
[provider-specific cluster configuration patch]({{< ref "..">}}) is included in the `ClusterClass`.

## Example

To specify additional tags for EKS resources, use the following configuration:

```yaml
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
name: <NAME>
spec:
topology:
variables:
- name: clusterConfig
value:
eks:
additionalTags:
Environment: production
Team: platform
CostCenter: "12345"
```

We can further customize individual MachineDeployments by using the overrides field with the following configuration:

```yaml
spec:
topology:
# ...
workers:
machineDeployments:
- class: default-worker
name: md-0
variables:
overrides:
- name: workerConfig
value:
eks:
additionalTags:
NodeType: worker
Workload: database
Environment: production
```

## Tag Precedence

When tags are specified at multiple levels, the following precedence applies (higher precedence overrides lower):

1. **Worker level tags** (highest precedence)
2. **Cluster level tags** (lowest precedence)

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.

## Applying this configuration will result in the following values being set

- `AWSManagedControlPlane`:

- ```yaml
spec:
template:
spec:
additionalTags:
Environment: production
Team: platform
CostCenter: "12345"
```

- worker `AWSMachineTemplate`:

- ```yaml
spec:
template:
spec:
additionalTags:
Environment: production
Team: platform
CostCenter: "12345"
NodeType: worker
Workload: general
```
4 changes: 4 additions & 0 deletions pkg/handlers/aws/mutation/metapatch_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/aws/mutation/placementgroup"
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/aws/mutation/region"
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/aws/mutation/securitygroups"
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/aws/mutation/tags"
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/aws/mutation/volumes"
genericmutation "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/mutation"
)
Expand All @@ -26,9 +27,11 @@ import (
func MetaPatchHandler(mgr manager.Manager) handlers.Named {
patchHandlers := []mutation.MetaMutator{
calico.NewPatch(),
tags.NewClusterPatch(),
region.NewPatch(),
network.NewPatch(),
controlplaneloadbalancer.NewPatch(),
tags.NewControlPlanePatch(),
identityref.NewPatch(),
iaminstanceprofile.NewControlPlanePatch(),
instancetype.NewControlPlanePatch(),
Expand All @@ -50,6 +53,7 @@ func MetaPatchHandler(mgr manager.Manager) handlers.Named {
// MetaWorkerPatchHandler returns a meta patch handler for mutating CAPA workers.
func MetaWorkerPatchHandler(mgr manager.Manager) handlers.Named {
patchHandlers := []mutation.MetaMutator{
tags.NewWorkerPatch(),
iaminstanceprofile.NewWorkerPatch(),
instancetype.NewWorkerPatch(),
ami.NewWorkerPatch(),
Expand Down
Loading
Loading