Skip to content

Commit 4ae9bc3

Browse files
committed
Fix comments
Signed-off-by: serngawy <[email protected]>
1 parent 667ce1a commit 4ae9bc3

25 files changed

+623
-940
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -783,8 +783,8 @@ spec:
783783
rule: self == oldSelf
784784
rosaRoleConfigRef:
785785
description: |-
786-
RosaRoleConfigRef is a reference to a RosaRoleConfig resource that contains account and operator roles and OIDC configuration.
787-
If specified, the roles and OIDC configuration will be taken from the referenced RosaRoleConfig instead of the direct fields.
786+
RosaRoleConfigRef is a reference to a RosaRoleConfig resource that contains account roles, operator roles and OIDC configuration.
787+
RosaRoleConfigRef and role fields such as installerRoleARN, supportRoleARN, workerRoleARN, rolesRef and oidcID are mutually exclusive.
788788
properties:
789789
name:
790790
default: ""

config/crd/bases/infrastructure.cluster.x-k8s.io_rosaroleconfigs.yaml

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,31 +48,44 @@ spec:
4848
creating your ROSA cluster.
4949
properties:
5050
path:
51+
description: The arn path for the account/operator roles as well
52+
as their policies.
5153
type: string
5254
permissionsBoundaryARN:
55+
description: The ARN of the policy that is used to set the permissions
56+
boundary for the account roles.
5357
type: string
5458
prefix:
55-
description: User-defined prefix for all generated AWS resources
59+
description: User-defined prefix for all generated AWS account
60+
role
5661
maxLength: 4
62+
pattern: ^[a-z]([-a-z0-9]*[a-z0-9])?$
5763
type: string
64+
x-kubernetes-validations:
65+
- message: prefix is immutable
66+
rule: self == oldSelf
5867
sharedVPCConfig:
5968
description: SharedVPCConfig is used to set up shared VPC.
6069
properties:
6170
routeRoleARN:
62-
description: ' Role ARN associated with the private hosted
63-
zone used for Hosted Control Plane cluster shared VPC, this
64-
role contains policies to be used with Route 53'
71+
description: Role ARN associated with the private hosted zone
72+
used for Hosted Control Plane cluster shared VPC, this role
73+
contains policies to be used with Route 53
6574
type: string
6675
vpcEndpointRoleArn:
67-
description: ' Role ARN associated with the shared VPC used
76+
description: Role ARN associated with the shared VPC used
6877
for Hosted Control Plane clusters, this role contains policies
69-
to be used with the VPC endpoint'
78+
to be used with the VPC endpoint
7079
type: string
7180
type: object
7281
version:
73-
description: ' Version of OpenShift that will be used to setup
74-
policy tag, for example "4.11"'
82+
description: |-
83+
Version of OpenShift that will be used to the roles tag in formate of x.y.z example; "4.19.0"
84+
Setting the role OpenShift version tag does not affect the associated ROSAControlplane version.
7585
type: string
86+
x-kubernetes-validations:
87+
- message: version is immutable
88+
rule: self == oldSelf
7689
required:
7790
- prefix
7891
- version
@@ -93,7 +106,9 @@ spec:
93106
type: object
94107
x-kubernetes-map-type: atomic
95108
identityRef:
96-
description: AWSIdentityReference specifies a identity.
109+
description: |-
110+
IdentityRef is a reference to an identity to be used when reconciling the ROSA Role Config.
111+
If no identity is specified, the default identity for this controller will be used.
97112
properties:
98113
kind:
99114
description: Kind of the identity.
@@ -110,43 +125,59 @@ spec:
110125
- kind
111126
- name
112127
type: object
128+
oidcProviderType:
129+
default: Managed
130+
description: OIDC provider type values are Managed or UnManaged. When
131+
set to UnManged OperatorRoleConfig OIDCID field must be provided.
132+
enum:
133+
- Managed
134+
- UnManaged
135+
type: string
113136
operatorRoleConfig:
114137
description: OperatorRoleConfig defines cluster-specific operator
115138
IAM roles based on your cluster configuration.
116139
properties:
117140
oidcID:
118141
description: |-
119142
OIDCID is the ID of the OIDC config that will be used to create the operator roles.
120-
A managed OIDC-provider will be created if the OIDCID not specified
143+
Cannot be set when OidcProviderType set to Managed
121144
type: string
145+
x-kubernetes-validations:
146+
- message: oidcID is immutable
147+
rule: self == oldSelf
122148
permissionsBoundaryARN:
123149
description: The ARN of the policy that is used to set the permissions
124150
boundary for the operator roles.
125151
type: string
126152
prefix:
127153
description: ' User-defined prefix for generated AWS operator
128-
policies.'
154+
roles.'
129155
maxLength: 4
156+
pattern: ^[a-z]([-a-z0-9]*[a-z0-9])?$
130157
type: string
158+
x-kubernetes-validations:
159+
- message: prefix is immutable
160+
rule: self == oldSelf
131161
sharedVPCConfig:
132162
description: SharedVPCConfig is used to set up shared VPC.
133163
properties:
134164
routeRoleARN:
135-
description: ' Role ARN associated with the private hosted
136-
zone used for Hosted Control Plane cluster shared VPC, this
137-
role contains policies to be used with Route 53'
165+
description: Role ARN associated with the private hosted zone
166+
used for Hosted Control Plane cluster shared VPC, this role
167+
contains policies to be used with Route 53
138168
type: string
139169
vpcEndpointRoleArn:
140-
description: ' Role ARN associated with the shared VPC used
170+
description: Role ARN associated with the shared VPC used
141171
for Hosted Control Plane clusters, this role contains policies
142-
to be used with the VPC endpoint'
172+
to be used with the VPC endpoint
143173
type: string
144174
type: object
145175
required:
146176
- prefix
147177
type: object
148178
required:
149179
- accountRoleConfig
180+
- oidcProviderType
150181
- operatorRoleConfig
151182
type: object
152183
status:
@@ -170,8 +201,7 @@ spec:
170201
type: string
171202
type: object
172203
conditions:
173-
description: Conditions provide observations of the operational state
174-
of a Cluster API resource.
204+
description: Conditions specifies the ROSARoleConfig conditions
175205
items:
176206
description: Condition defines an observation of a Cluster API resource
177207
operational state.

config/crd/kustomization.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ patchesStrategicMerge:
4242
- patches/webhook_in_awsmanagedcontrolplanetemplates.yaml
4343
- patches/webhook_in_eksconfigs.yaml
4444
- patches/webhook_in_eksconfigtemplates.yaml
45-
- patches/webhook_in_rosaroleconfigs.yaml
4645
# +kubebuilder:scaffold:crdkustomizewebhookpatch
4746

4847
# [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix.

config/crd/patches/webhook_in_rosaroleconfigs.yaml

Lines changed: 0 additions & 16 deletions
This file was deleted.

config/rbac/role.yaml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,6 @@ rules:
135135
- patch
136136
- update
137137
- watch
138-
- apiGroups:
139-
- controlplane.cluster.x-k8s.io
140-
resources:
141-
- rosacontrolplanes/finalizers
142-
verbs:
143-
- update
144138
- apiGroups:
145139
- infrastructure.cluster.x-k8s.io
146140
resources:
@@ -169,7 +163,6 @@ rules:
169163
- awsmanagedclusters
170164
- awsmanagedmachinepools
171165
- rosaclusters
172-
- rosamachinepools
173166
verbs:
174167
- delete
175168
- get
@@ -183,7 +176,6 @@ rules:
183176
- awsclusters/status
184177
- awsfargateprofiles/status
185178
- rosaclusters/status
186-
- rosamachinepools/status
187179
- rosaroleconfigs/status
188180
verbs:
189181
- get
@@ -207,6 +199,7 @@ rules:
207199
resources:
208200
- awsmachines
209201
- rosamachinepools
202+
- rosaroleconfigs
210203
verbs:
211204
- create
212205
- delete
@@ -222,3 +215,14 @@ rules:
222215
- rosaroleconfigs/finalizers
223216
verbs:
224217
- update
218+
- apiGroups:
219+
- infrastructure.cluster.x-k8s.io
220+
resources:
221+
- rosamachinepools/status
222+
verbs:
223+
- create
224+
- get
225+
- list
226+
- patch
227+
- update
228+
- watch

controllers/rosacluster_controller_test.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,19 @@ func TestRosaClusterReconcile(t *testing.T) {
9595
PodCIDR: "10.128.0.0/14",
9696
ServiceCIDR: "172.30.0.0/16",
9797
},
98-
Region: "us-east-1",
99-
Version: "4.19.20",
100-
ChannelGroup: "stable",
101-
RolesRef: rosacontrolplanev1.AWSRolesRef{},
98+
Region: "us-east-1",
99+
Version: "4.19.20",
100+
ChannelGroup: "stable",
101+
RolesRef: rosacontrolplanev1.AWSRolesRef{
102+
IngressARN: "ingress-arn",
103+
ImageRegistryARN: "image-arn",
104+
StorageARN: "storage-arn",
105+
NetworkARN: "net-arn",
106+
KubeCloudControllerARN: "kube-arn",
107+
NodePoolManagementARN: "node-arn",
108+
ControlPlaneOperatorARN: "control-arn",
109+
KMSProviderARN: "kms-arn",
110+
},
102111
OIDCID: "oidcid1",
103112
InstallerRoleARN: "arn1",
104113
WorkerRoleARN: "arn2",

controlplane/rosa/api/v1beta2/rosacontrolplane_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ type RosaControlPlaneSpec struct { //nolint: maligned
126126
// +kubebuilder:default=WaitForAcknowledge
127127
VersionGate VersionGateAckType `json:"versionGate"`
128128

129-
// RosaRoleConfigRef is a reference to a RosaRoleConfig resource that contains account and operator roles and OIDC configuration.
130-
// If specified, the roles and OIDC configuration will be taken from the referenced RosaRoleConfig instead of the direct fields.
129+
// RosaRoleConfigRef is a reference to a RosaRoleConfig resource that contains account roles, operator roles and OIDC configuration.
130+
// RosaRoleConfigRef and role fields such as installerRoleARN, supportRoleARN, workerRoleARN, rolesRef and oidcID are mutually exclusive.
131131
//
132132
// +optional
133133
RosaRoleConfigRef *corev1.LocalObjectReference `json:"rosaRoleConfigRef,omitempty"`

controlplane/rosa/api/v1beta2/rosacontrolplane_webhook.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ import (
3131
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
3232
)
3333

34-
// log is for logging in this package.
35-
var rosacpLog = ctrl.Log.WithName("rosacontrolplane-resource")
36-
3734
// SetupWebhookWithManager will setup the webhooks for the ROSAControlPlane.
3835
func (r *ROSAControlPlane) SetupWebhookWithManager(mgr ctrl.Manager) error {
3936
w := new(rosaControlPlaneWebhook)
@@ -124,6 +121,10 @@ func (*rosaControlPlaneWebhook) ValidateUpdate(_ context.Context, oldObj, newObj
124121
allErrs = append(allErrs, err)
125122
}
126123

124+
if err := r.validateRosaRoleConfig(); err != nil {
125+
allErrs = append(allErrs, err)
126+
}
127+
127128
allErrs = append(allErrs, r.validateNetwork()...)
128129
allErrs = append(allErrs, r.Spec.AdditionalTags.Validate()...)
129130

@@ -203,14 +204,14 @@ func (r *ROSAControlPlane) validateExternalAuthProviders() *field.Error {
203204
}
204205

205206
func (r *ROSAControlPlane) validateRosaRoleConfig() *field.Error {
206-
hasAnyDirectRoleFields := r.Spec.OIDCID != "" || r.Spec.InstallerRoleARN != "" || r.Spec.SupportRoleARN != "" || r.Spec.WorkerRoleARN != "" ||
207+
hasRoleFields := r.Spec.OIDCID != "" || r.Spec.InstallerRoleARN != "" || r.Spec.SupportRoleARN != "" || r.Spec.WorkerRoleARN != "" ||
207208
r.Spec.RolesRef.IngressARN != "" || r.Spec.RolesRef.ImageRegistryARN != "" || r.Spec.RolesRef.StorageARN != "" ||
208209
r.Spec.RolesRef.NetworkARN != "" || r.Spec.RolesRef.KubeCloudControllerARN != "" || r.Spec.RolesRef.NodePoolManagementARN != "" ||
209210
r.Spec.RolesRef.ControlPlaneOperatorARN != "" || r.Spec.RolesRef.KMSProviderARN != ""
210211

211212
if r.Spec.RosaRoleConfigRef != nil {
212-
if hasAnyDirectRoleFields {
213-
rosacpLog.Info("rosaRoleConfigRef and direct role fields (oidcID, installerRoleARN, supportRoleARN, workerRoleARN, rolesRef) are mutually exclusive")
213+
if hasRoleFields {
214+
return field.Invalid(field.NewPath("spec.rosaRoleConfigRef"), r.Spec.RosaRoleConfigRef, "RosaRoleConfigRef and role fields such as installerRoleARN, supportRoleARN, workerRoleARN, rolesRef and oidcID are mutually exclusive")
214215
}
215216
return nil
216217
}

0 commit comments

Comments
 (0)