Skip to content

Commit f0a5ecf

Browse files
authored
Merge pull request #4804 from muraee/reconcile-rosa-machinepool
✨ ROSA: Reconcile ROSAMachinePool fields
2 parents 77aed2a + 3defa28 commit f0a5ecf

16 files changed

+669
-151
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,6 @@ spec:
341341
version:
342342
description: OpenShift semantic version, for example "4.14.5".
343343
type: string
344-
x-kubernetes-validations:
345-
- message: version must be a valid semantic version
346-
rule: self.matches('^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$')
347344
workerRoleARN:
348345
type: string
349346
required:

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

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,48 @@ spec:
9494
type: array
9595
subnet:
9696
type: string
97+
x-kubernetes-validations:
98+
- message: subnet is immutable
99+
rule: self == oldSelf
100+
taints:
101+
description: Taints specifies the taints to apply to the nodes of
102+
the machine pool
103+
items:
104+
properties:
105+
effect:
106+
description: The effect of the taint on pods that do not tolerate
107+
the taint. Valid effects are NoSchedule, PreferNoSchedule
108+
and NoExecute.
109+
enum:
110+
- NoSchedule
111+
- PreferNoSchedule
112+
- NoExecute
113+
type: string
114+
key:
115+
description: The taint key to be applied to a node.
116+
type: string
117+
value:
118+
description: The taint value corresponding to the taint key.
119+
pattern: ^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$
120+
type: string
121+
required:
122+
- effect
123+
- key
124+
type: object
125+
type: array
126+
tuningConfigs:
127+
description: TuningConfigs specifies the names of the tuning configs
128+
to be applied to this MachinePool. Tuning configs must already exist.
129+
items:
130+
type: string
131+
type: array
97132
version:
98-
description: Version specifies the penshift version of the nodes associated
99-
with this machinepool. ROSAControlPlane version is used if not set.
133+
description: Version specifies the OpenShift version of the nodes
134+
associated with this machinepool. ROSAControlPlane version is used
135+
if not set.
100136
type: string
101-
x-kubernetes-validations:
102-
- message: version must be a valid semantic version
103-
rule: self.matches('^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$')
104137
required:
138+
- instanceType
105139
- nodePoolName
106140
type: object
107141
status:

config/rbac/role.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ rules:
175175
- get
176176
- list
177177
- watch
178+
- apiGroups:
179+
- controlplane.cluster.x-k8s.io
180+
resources:
181+
- rosacontrolplanes/finalizers
182+
verbs:
183+
- update
178184
- apiGroups:
179185
- controlplane.cluster.x-k8s.io
180186
resources:
@@ -409,6 +415,12 @@ rules:
409415
- patch
410416
- update
411417
- watch
418+
- apiGroups:
419+
- infrastructure.cluster.x-k8s.io
420+
resources:
421+
- rosamachinepools/finalizers
422+
verbs:
423+
- update
412424
- apiGroups:
413425
- infrastructure.cluster.x-k8s.io
414426
resources:

config/webhook/manifests.yaml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,28 @@ webhooks:
201201
resources:
202202
- awsmanagedmachinepools
203203
sideEffects: None
204+
- admissionReviewVersions:
205+
- v1
206+
- v1beta1
207+
clientConfig:
208+
service:
209+
name: webhook-service
210+
namespace: system
211+
path: /mutate-infrastructure-cluster-x-k8s-io-v1beta2-rosamachinepool
212+
failurePolicy: Fail
213+
matchPolicy: Equivalent
214+
name: default.rosamachinepool.infrastructure.cluster.x-k8s.io
215+
rules:
216+
- apiGroups:
217+
- infrastructure.cluster.x-k8s.io
218+
apiVersions:
219+
- v1beta2
220+
operations:
221+
- CREATE
222+
- UPDATE
223+
resources:
224+
- rosamachinepools
225+
sideEffects: None
204226
- admissionReviewVersions:
205227
- v1
206228
- v1beta1
@@ -267,6 +289,28 @@ webhooks:
267289
resources:
268290
- awsmanagedcontrolplanes
269291
sideEffects: None
292+
- admissionReviewVersions:
293+
- v1
294+
- v1beta1
295+
clientConfig:
296+
service:
297+
name: webhook-service
298+
namespace: system
299+
path: /mutate-controlplane-cluster-x-k8s-io-v1beta2-rosacontrolplane
300+
failurePolicy: Fail
301+
matchPolicy: Equivalent
302+
name: default.rosacontrolplanes.controlplane.cluster.x-k8s.io
303+
rules:
304+
- apiGroups:
305+
- controlplane.cluster.x-k8s.io
306+
apiVersions:
307+
- v1beta2
308+
operations:
309+
- CREATE
310+
- UPDATE
311+
resources:
312+
- rosacontrolplanes
313+
sideEffects: None
270314
---
271315
apiVersion: admissionregistration.k8s.io/v1
272316
kind: ValidatingWebhookConfiguration
@@ -493,6 +537,28 @@ webhooks:
493537
resources:
494538
- awsmanagedmachinepools
495539
sideEffects: None
540+
- admissionReviewVersions:
541+
- v1
542+
- v1beta1
543+
clientConfig:
544+
service:
545+
name: webhook-service
546+
namespace: system
547+
path: /validate-infrastructure-cluster-x-k8s-io-v1beta2-rosamachinepool
548+
failurePolicy: Fail
549+
matchPolicy: Equivalent
550+
name: validation.rosamachinepool.infrastructure.cluster.x-k8s.io
551+
rules:
552+
- apiGroups:
553+
- infrastructure.cluster.x-k8s.io
554+
apiVersions:
555+
- v1beta2
556+
operations:
557+
- CREATE
558+
- UPDATE
559+
resources:
560+
- rosamachinepools
561+
sideEffects: None
496562
- admissionReviewVersions:
497563
- v1
498564
- v1beta1
@@ -559,3 +625,25 @@ webhooks:
559625
resources:
560626
- awsmanagedcontrolplanes
561627
sideEffects: None
628+
- admissionReviewVersions:
629+
- v1
630+
- v1beta1
631+
clientConfig:
632+
service:
633+
name: webhook-service
634+
namespace: system
635+
path: /validate-controlplane-cluster-x-k8s-io-v1beta2-rosacontrolplane
636+
failurePolicy: Fail
637+
matchPolicy: Equivalent
638+
name: validation.rosacontrolplanes.controlplane.cluster.x-k8s.io
639+
rules:
640+
- apiGroups:
641+
- controlplane.cluster.x-k8s.io
642+
apiVersions:
643+
- v1beta2
644+
operations:
645+
- CREATE
646+
- UPDATE
647+
resources:
648+
- rosacontrolplanes
649+
sideEffects: None

controlplane/rosa/api/v1beta2/conditions_consts.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ const (
2222
// ROSAControlPlaneReadyCondition condition reports on the successful reconciliation of ROSAControlPlane.
2323
ROSAControlPlaneReadyCondition clusterv1.ConditionType = "ROSAControlPlaneReady"
2424

25+
// ROSAControlPlaneValidCondition condition reports whether ROSAControlPlane configuration is valid.
26+
ROSAControlPlaneValidCondition clusterv1.ConditionType = "ROSAControlPlaneValid"
27+
2528
// ROSAControlPlaneUpgradingCondition condition reports whether ROSAControlPlane is upgrading or not.
2629
ROSAControlPlaneUpgradingCondition clusterv1.ConditionType = "ROSAControlPlaneUpgrading"
30+
31+
// ROSAControlPlaneReconciliationFailedReason used to report failures while reconciling ROSAControlPlane.
32+
ROSAControlPlaneReconciliationFailedReason = "ReconciliationFailed"
33+
34+
// ROSAControlPlaneInvalidConfigurationReason used to report invalid user input.
35+
ROSAControlPlaneInvalidConfigurationReason = "InvalidConfiguration"
2736
)

controlplane/rosa/api/v1beta2/rosacontrolplane_types.go

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ type RosaControlPlaneSpec struct { //nolint: maligned
3030
// characters or '-', start with an alphabetic character, end with an alphanumeric character
3131
// and have a max length of 15 characters.
3232
//
33-
// +immutable
3433
// +kubebuilder:validation:XValidation:rule="self == oldSelf", message="rosaClusterName is immutable"
3534
// +kubebuilder:validation:MaxLength:=15
3635
// +kubebuilder:validation:Pattern:=`^[a-z]([-a-z0-9]*[a-z0-9])?$`
36+
// +immutable
3737
RosaClusterName string `json:"rosaClusterName"`
3838

3939
// The Subnet IDs to use when installing the cluster.
@@ -45,35 +45,31 @@ type RosaControlPlaneSpec struct { //nolint: maligned
4545
AvailabilityZones []string `json:"availabilityZones"`
4646

4747
// The AWS Region the cluster lives in.
48-
Region *string `json:"region"`
48+
Region string `json:"region"`
4949

5050
// OpenShift semantic version, for example "4.14.5".
51-
// +kubebuilder:validation:XValidation:rule=`self.matches('^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$')`, message="version must be a valid semantic version"
5251
Version string `json:"version"`
5352

54-
// ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
55-
// +optional
56-
ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"`
57-
5853
// AWS IAM roles used to perform credential requests by the openshift operators.
5954
RolesRef AWSRolesRef `json:"rolesRef"`
6055

6156
// The ID of the OpenID Connect Provider.
62-
OIDCID *string `json:"oidcID"`
57+
OIDCID string `json:"oidcID"`
6358

6459
// TODO: these are to satisfy ocm sdk. Explore how to drop them.
6560
InstallerRoleARN *string `json:"installerRoleARN"`
6661
SupportRoleARN *string `json:"supportRoleARN"`
6762
WorkerRoleARN *string `json:"workerRoleARN"`
6863

69-
// +immutable
70-
// +kubebuilder:validation:Optional
71-
// +kubebuilder:validation:XValidation:rule="self == oldSelf", message="billingAccount is immutable"
72-
// +kubebuilder:validation:XValidation:rule="self.matches('^[0-9]{12}$')", message="billingAccount must be a valid AWS account ID"
73-
7464
// BillingAccount is an optional AWS account to use for billing the subscription fees for ROSA clusters.
7565
// The cost of running each ROSA cluster will be billed to the infrastructure account in which the cluster
7666
// is running.
67+
//
68+
// +kubebuilder:validation:Optional
69+
// +kubebuilder:validation:XValidation:rule="self == oldSelf", message="billingAccount is immutable"
70+
// +kubebuilder:validation:XValidation:rule="self.matches('^[0-9]{12}$')", message="billingAccount must be a valid AWS account ID"
71+
// +immutable
72+
// +optional
7773
BillingAccount string `json:"billingAccount,omitempty"`
7874

7975
// CredentialsSecretRef references a secret with necessary credentials to connect to the OCM API.
@@ -83,13 +79,14 @@ type RosaControlPlaneSpec struct { //nolint: maligned
8379
// +optional
8480
CredentialsSecretRef *corev1.LocalObjectReference `json:"credentialsSecretRef,omitempty"`
8581

86-
// +optional
87-
8882
// IdentityRef is a reference to an identity to be used when reconciling the managed control plane.
8983
// If no identity is specified, the default identity for this controller will be used.
84+
//
85+
// +optional
9086
IdentityRef *infrav1.AWSIdentityReference `json:"identityRef,omitempty"`
9187

9288
// Network config for the ROSA HCP cluster.
89+
// +optional
9390
Network *NetworkSpec `json:"network,omitempty"`
9491

9592
// The instance type to use, for example `r5.xlarge`. Instance type ref; https://aws.amazon.com/ec2/instance-types/
@@ -99,12 +96,17 @@ type RosaControlPlaneSpec struct { //nolint: maligned
9996
// Autoscaling specifies auto scaling behaviour for the MachinePools.
10097
// +optional
10198
Autoscaling *expinfrav1.RosaMachinePoolAutoScaling `json:"autoscaling,omitempty"`
99+
100+
// ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
101+
// +optional
102+
ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"`
102103
}
103104

104105
// NetworkSpec for ROSA-HCP.
105106
type NetworkSpec struct {
106107
// IP addresses block used by OpenShift while installing the cluster, for example "10.0.0.0/16".
107108
// +kubebuilder:validation:Format=cidr
109+
// +optional
108110
MachineCIDR string `json:"machineCIDR,omitempty"`
109111

110112
// IP address block from which to assign pod IP addresses, for example `10.128.0.0/14`.
@@ -125,6 +127,7 @@ type NetworkSpec struct {
125127
// The CNI network type default is OVNKubernetes.
126128
// +kubebuilder:validation:Enum=OVNKubernetes;Other
127129
// +kubebuilder:default=OVNKubernetes
130+
// +optional
128131
NetworkType string `json:"networkType,omitempty"`
129132
}
130133

@@ -533,7 +536,7 @@ type RosaControlPlaneStatus struct {
533536
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
534537

535538
// ID is the cluster ID given by ROSA.
536-
ID *string `json:"id,omitempty"`
539+
ID string `json:"id,omitempty"`
537540
// ConsoleURL is the url for the openshift console.
538541
ConsoleURL string `json:"consoleURL,omitempty"`
539542
// OIDCEndpointURL is the endpoint url for the managed OIDC porvider.

0 commit comments

Comments
 (0)