Skip to content

Commit be41c4f

Browse files
xiangjinglimuraee
authored andcommitted
Add missing Fields to RosaControlPlane - tags, etcdEncryption
Signed-off-by: Xiangjing Li <[email protected]>
1 parent f103bff commit be41c4f

File tree

7 files changed

+50
-4
lines changed

7 files changed

+50
-4
lines changed

config/crd/bases/controlplane.cluster.x-k8s.io_rosacontrolplanes.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ spec:
4747
spec:
4848
description: RosaControlPlaneSpec defines the desired state of ROSAControlPlane.
4949
properties:
50+
additionalTags:
51+
additionalProperties:
52+
type: string
53+
description: AdditionalTags are user-defined tags to be added on the
54+
AWS resources associated with the control plane.
55+
type: object
5056
autoscaling:
5157
description: Autoscaling specifies auto scaling behaviour for the
5258
MachinePools.
@@ -102,6 +108,11 @@ spec:
102108
type: string
103109
type: object
104110
x-kubernetes-map-type: atomic
111+
etcdEncryptionKMSArn:
112+
description: EtcdEncryptionKMSArn is the ARN of the KMS key used to
113+
encrypt etcd. The key itself needs to be created out-of-band by
114+
the user and tagged with `red-hat:true`.
115+
type: string
105116
identityRef:
106117
description: IdentityRef is a reference to an identity to be used
107118
when reconciling the managed control plane. If no identity is specified,

controlplane/rosa/api/v1beta2/rosacontrolplane_types.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ type RosaControlPlaneSpec struct { //nolint: maligned
9898
// +optional
9999
Autoscaling *expinfrav1.RosaMachinePoolAutoScaling `json:"autoscaling,omitempty"`
100100

101+
// AdditionalTags are user-defined tags to be added on the AWS resources associated with the control plane.
102+
// +optional
103+
AdditionalTags infrav1.Tags `json:"additionalTags,omitempty"`
104+
105+
// EtcdEncryptionKMSArn is the ARN of the KMS key used to encrypt etcd. The key itself needs to be
106+
// created out-of-band by the user and tagged with `red-hat:true`.
107+
// +optional
108+
EtcdEncryptionKMSArn string `json:"etcdEncryptionKMSArn,omitempty"`
109+
101110
// ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
102111
// +optional
103112
ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"`

controlplane/rosa/api/v1beta2/rosacontrolplane_webhook.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"net"
55

66
"github.com/blang/semver"
7+
kmsArnRegexpValidator "github.com/openshift-online/ocm-common/pkg/resource/validations"
78
apierrors "k8s.io/apimachinery/pkg/api/errors"
89
runtime "k8s.io/apimachinery/pkg/runtime"
910
"k8s.io/apimachinery/pkg/util/validation/field"
@@ -33,7 +34,12 @@ func (r *ROSAControlPlane) ValidateCreate() (warnings admission.Warnings, err er
3334
allErrs = append(allErrs, err)
3435
}
3536

37+
if err := r.validateEtcdEncryptionKMSArn(); err != nil {
38+
allErrs = append(allErrs, err)
39+
}
40+
3641
allErrs = append(allErrs, r.validateNetwork()...)
42+
allErrs = append(allErrs, r.Spec.AdditionalTags.Validate()...)
3743

3844
if len(allErrs) == 0 {
3945
return nil, nil
@@ -54,7 +60,12 @@ func (r *ROSAControlPlane) ValidateUpdate(old runtime.Object) (warnings admissio
5460
allErrs = append(allErrs, err)
5561
}
5662

63+
if err := r.validateEtcdEncryptionKMSArn(); err != nil {
64+
allErrs = append(allErrs, err)
65+
}
66+
5767
allErrs = append(allErrs, r.validateNetwork()...)
68+
allErrs = append(allErrs, r.Spec.AdditionalTags.Validate()...)
5869

5970
if len(allErrs) == 0 {
6071
return nil, nil
@@ -113,6 +124,15 @@ func (r *ROSAControlPlane) validateNetwork() field.ErrorList {
113124
return allErrs
114125
}
115126

127+
func (r *ROSAControlPlane) validateEtcdEncryptionKMSArn() *field.Error {
128+
err := kmsArnRegexpValidator.ValidateKMSKeyARN(&r.Spec.EtcdEncryptionKMSArn)
129+
if err != nil {
130+
return field.Invalid(field.NewPath("spec.EtcdEncryptionKMSArn"), r.Spec.EtcdEncryptionKMSArn, err.Error())
131+
}
132+
133+
return nil
134+
}
135+
116136
// Default implements admission.Defaulter.
117137
func (r *ROSAControlPlane) Default() {
118138
SetObjectDefaults_ROSAControlPlane(r)

controlplane/rosa/api/v1beta2/zz_generated.deepcopy.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controlplane/rosa/controllers/rosacontrolplane_controller.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,9 @@ func (r *ROSAControlPlaneReconciler) reconcileNormal(ctx context.Context, rosaSc
284284
DisableWorkloadMonitoring: ptr.To(true),
285285
DefaultIngress: ocm.NewDefaultIngressSpec(), // n.b. this is a no-op when it's set to the default value
286286
ComputeMachineType: rosaScope.ControlPlane.Spec.InstanceType,
287+
Tags: rosaScope.ControlPlane.Spec.AdditionalTags,
288+
EtcdEncryption: rosaScope.ControlPlane.Spec.EtcdEncryptionKMSArn != "",
289+
EtcdEncryptionKMSArn: rosaScope.ControlPlane.Spec.EtcdEncryptionKMSArn,
287290

288291
SubnetIds: rosaScope.ControlPlane.Spec.Subnets,
289292
AvailabilityZones: rosaScope.ControlPlane.Spec.AvailabilityZones,

templates/cluster-template-rosa-machinepool.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ spec:
3030
rosaClusterName: ${CLUSTER_NAME:0:15}
3131
version: "${OPENSHIFT_VERSION}"
3232
region: "${AWS_REGION}"
33-
accountID: "${AWS_ACCOUNT_ID}"
34-
creatorARN: "${AWS_CREATOR_ARN}"
3533
network:
3634
machineCIDR: "10.0.0.0/16"
3735
rolesRef:

templates/cluster-template-rosa.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ spec:
3030
rosaClusterName: ${CLUSTER_NAME:0:15}
3131
version: "${OPENSHIFT_VERSION}"
3232
region: "${AWS_REGION}"
33-
accountID: "${AWS_ACCOUNT_ID}"
34-
creatorARN: "${AWS_CREATOR_ARN}"
3533
network:
3634
machineCIDR: "10.0.0.0/16"
3735
rolesRef:

0 commit comments

Comments
 (0)