Skip to content

Commit 0647b20

Browse files
authored
Merge pull request #4725 from muraee/rosa-machine-mgmt
✨ ROSA machinePools support
2 parents c777c9d + 74a0ce7 commit 0647b20

24 files changed

+1509
-148
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ spec:
7272
type: object
7373
creatorARN:
7474
type: string
75+
credentialsSecretRef:
76+
description: 'CredentialsSecretRef references a secret with necessary
77+
credentials to connect to the OCM API. The secret should contain
78+
the following data keys: - ocmToken: eyJhbGciOiJIUzI1NiIsI.... -
79+
ocmApiUrl: Optional, defaults to ''https://api.openshift.com'''
80+
properties:
81+
name:
82+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
83+
TODO: Add other useful fields. apiVersion, kind, uid?'
84+
type: string
85+
type: object
86+
x-kubernetes-map-type: atomic
7587
installerRoleARN:
7688
type: string
7789
machineCIDR:
@@ -237,6 +249,17 @@ spec:
237249
- nodePoolManagementARN
238250
- storageARN
239251
type: object
252+
rosaClusterName:
253+
description: Cluster name must be valid DNS-1035 label, so it must
254+
consist of lower case alphanumeric characters or '-', start with
255+
an alphabetic character, end with an alphanumeric character and
256+
have a max length of 15 characters.
257+
maxLength: 15
258+
pattern: ^[a-z]([-a-z0-9]*[a-z0-9])?$
259+
type: string
260+
x-kubernetes-validations:
261+
- message: rosaClusterName is immutable
262+
rule: self == oldSelf
240263
subnets:
241264
description: The Subnet IDs to use when installing the cluster. SubnetIDs
242265
should come in pairs; two per availability zone, one private and
@@ -249,6 +272,8 @@ spec:
249272
version:
250273
description: Openshift version, for example "openshift-v4.12.15".
251274
type: string
275+
workerRoleARN:
276+
type: string
252277
required:
253278
- accountID
254279
- availabilityZones
@@ -258,9 +283,11 @@ spec:
258283
- oidcID
259284
- region
260285
- rolesRef
286+
- rosaClusterName
261287
- subnets
262288
- supportRoleARN
263289
- version
290+
- workerRoleARN
264291
type: object
265292
status:
266293
properties:
@@ -320,6 +347,9 @@ spec:
320347
description: ErrorMessage indicates that there is a terminal problem
321348
reconciling the state, and will be set to a descriptive error message.
322349
type: string
350+
id:
351+
description: ID is the cluster ID given by ROSA.
352+
type: string
323353
initialized:
324354
description: Initialized denotes whether or not the control plane
325355
has the uploaded kubernetes config-map.
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.12.1
7+
name: rosamachinepools.infrastructure.cluster.x-k8s.io
8+
spec:
9+
group: infrastructure.cluster.x-k8s.io
10+
names:
11+
categories:
12+
- cluster-api
13+
kind: ROSAMachinePool
14+
listKind: ROSAMachinePoolList
15+
plural: rosamachinepools
16+
shortNames:
17+
- rosamp
18+
singular: rosamachinepool
19+
scope: Namespaced
20+
versions:
21+
- additionalPrinterColumns:
22+
- description: MachinePool ready status
23+
jsonPath: .status.ready
24+
name: Ready
25+
type: string
26+
- description: Number of replicas
27+
jsonPath: .status.replicas
28+
name: Replicas
29+
type: integer
30+
name: v1beta2
31+
schema:
32+
openAPIV3Schema:
33+
description: ROSAMachinePool is the Schema for the rosamachinepools API.
34+
properties:
35+
apiVersion:
36+
description: 'APIVersion defines the versioned schema of this representation
37+
of an object. Servers should convert recognized schemas to the latest
38+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
39+
type: string
40+
kind:
41+
description: 'Kind is a string value representing the REST resource this
42+
object represents. Servers may infer this from the endpoint the client
43+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
44+
type: string
45+
metadata:
46+
type: object
47+
spec:
48+
description: RosaMachinePoolSpec defines the desired state of RosaMachinePool.
49+
properties:
50+
autoRepair:
51+
default: false
52+
description: AutoRepair specifies whether health checks should be
53+
enabled for machines in the NodePool. The default is false.
54+
type: boolean
55+
autoscaling:
56+
description: Autoscaling specifies auto scaling behaviour for this
57+
MachinePool. required if Replicas is not configured
58+
properties:
59+
maxReplicas:
60+
minimum: 1
61+
type: integer
62+
minReplicas:
63+
minimum: 1
64+
type: integer
65+
type: object
66+
availabilityZone:
67+
description: AvailabilityZone is an optinal field specifying the availability
68+
zone where instances of this machine pool should run For Multi-AZ
69+
clusters, you can create a machine pool in a Single-AZ of your choice.
70+
type: string
71+
instanceType:
72+
description: InstanceType specifies the AWS instance type
73+
type: string
74+
labels:
75+
additionalProperties:
76+
type: string
77+
description: Labels specifies labels for the Kubernetes node objects
78+
type: object
79+
nodePoolName:
80+
description: NodePoolName specifies the name of the nodepool in Rosa
81+
must be a valid DNS-1035 label, so it must consist of lower case
82+
alphanumeric and have a max length of 15 characters.
83+
maxLength: 15
84+
pattern: ^[a-z]([-a-z0-9]*[a-z0-9])?$
85+
type: string
86+
x-kubernetes-validations:
87+
- message: nodepoolName is immutable
88+
rule: self == oldSelf
89+
providerIDList:
90+
description: ProviderIDList contain a ProviderID for each machine
91+
instance that's currently managed by this machine pool.
92+
items:
93+
type: string
94+
type: array
95+
subnet:
96+
type: string
97+
required:
98+
- nodePoolName
99+
type: object
100+
status:
101+
description: RosaMachinePoolStatus defines the observed state of RosaMachinePool.
102+
properties:
103+
conditions:
104+
description: Conditions defines current service state of the managed
105+
machine pool
106+
items:
107+
description: Condition defines an observation of a Cluster API resource
108+
operational state.
109+
properties:
110+
lastTransitionTime:
111+
description: Last time the condition transitioned from one status
112+
to another. This should be when the underlying condition changed.
113+
If that is not known, then using the time when the API field
114+
changed is acceptable.
115+
format: date-time
116+
type: string
117+
message:
118+
description: A human readable message indicating details about
119+
the transition. This field may be empty.
120+
type: string
121+
reason:
122+
description: The reason for the condition's last transition
123+
in CamelCase. The specific API may choose whether or not this
124+
field is considered a guaranteed API. This field may not be
125+
empty.
126+
type: string
127+
severity:
128+
description: Severity provides an explicit classification of
129+
Reason code, so the users or machines can immediately understand
130+
the current situation and act accordingly. The Severity field
131+
MUST be set only when Status=False.
132+
type: string
133+
status:
134+
description: Status of the condition, one of True, False, Unknown.
135+
type: string
136+
type:
137+
description: Type of condition in CamelCase or in foo.example.com/CamelCase.
138+
Many .condition.type values are consistent across resources
139+
like Available, but because arbitrary conditions can be useful
140+
(see .node.status.conditions), the ability to deconflict is
141+
important.
142+
type: string
143+
required:
144+
- lastTransitionTime
145+
- status
146+
- type
147+
type: object
148+
type: array
149+
id:
150+
description: ID is the ID given by ROSA.
151+
type: string
152+
ready:
153+
default: false
154+
description: Ready denotes that the RosaMachinePool nodepool has joined
155+
the cluster
156+
type: boolean
157+
replicas:
158+
description: Replicas is the most recently observed number of replicas.
159+
format: int32
160+
type: integer
161+
required:
162+
- ready
163+
type: object
164+
type: object
165+
served: true
166+
storage: true
167+
subresources:
168+
status: {}

config/crd/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ resources:
2323
- bases/bootstrap.cluster.x-k8s.io_eksconfigtemplates.yaml
2424
- bases/controlplane.cluster.x-k8s.io_rosacontrolplanes.yaml
2525
- bases/infrastructure.cluster.x-k8s.io_rosaclusters.yaml
26+
- bases/infrastructure.cluster.x-k8s.io_rosamachinepools.yaml
2627
# +kubebuilder:scaffold:crdkustomizeresource
2728

2829
patchesStrategicMerge:

config/rbac/role.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,3 +378,22 @@ rules:
378378
- get
379379
- patch
380380
- update
381+
- apiGroups:
382+
- infrastructure.cluster.x-k8s.io
383+
resources:
384+
- rosamachinenepools
385+
verbs:
386+
- delete
387+
- get
388+
- list
389+
- patch
390+
- update
391+
- watch
392+
- apiGroups:
393+
- infrastructure.cluster.x-k8s.io
394+
resources:
395+
- rosamachinenepools/status
396+
verbs:
397+
- get
398+
- patch
399+
- update
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
Copyright 2022 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta2
18+
19+
import clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
20+
21+
const (
22+
// ROSAControlPlaneReadyCondition condition reports on the successful reconciliation of ROSAControlPlane.
23+
ROSAControlPlaneReadyCondition clusterv1.ConditionType = "ROSAControlPlaneReady"
24+
)

controlplane/rosa/api/v1beta2/rosacontrolplane_types.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,23 @@ limitations under the License.
1717
package v1beta2
1818

1919
import (
20+
corev1 "k8s.io/api/core/v1"
2021
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2122

2223
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2324
)
2425

2526
type RosaControlPlaneSpec struct { //nolint: maligned
27+
// Cluster name must be valid DNS-1035 label, so it must consist of lower case alphanumeric
28+
// characters or '-', start with an alphabetic character, end with an alphanumeric character
29+
// and have a max length of 15 characters.
30+
//
31+
// +immutable
32+
// +kubebuilder:validation:XValidation:rule="self == oldSelf", message="rosaClusterName is immutable"
33+
// +kubebuilder:validation:MaxLength:=15
34+
// +kubebuilder:validation:Pattern:=`^[a-z]([-a-z0-9]*[a-z0-9])?$`
35+
RosaClusterName string `json:"rosaClusterName"`
36+
2637
// The Subnet IDs to use when installing the cluster.
2738
// SubnetIDs should come in pairs; two per availability zone, one private and one public.
2839
Subnets []string `json:"subnets"`
@@ -55,6 +66,14 @@ type RosaControlPlaneSpec struct { //nolint: maligned
5566
CreatorARN *string `json:"creatorARN"`
5667
InstallerRoleARN *string `json:"installerRoleARN"`
5768
SupportRoleARN *string `json:"supportRoleARN"`
69+
WorkerRoleARN *string `json:"workerRoleARN"`
70+
71+
// CredentialsSecretRef references a secret with necessary credentials to connect to the OCM API.
72+
// The secret should contain the following data keys:
73+
// - ocmToken: eyJhbGciOiJIUzI1NiIsI....
74+
// - ocmApiUrl: Optional, defaults to 'https://api.openshift.com'
75+
// +optional
76+
CredentialsSecretRef *corev1.LocalObjectReference `json:"credentialsSecretRef,omitempty"`
5877
}
5978

6079
// AWSRolesRef contains references to various AWS IAM roles required for operators to make calls against the AWS API.
@@ -454,6 +473,9 @@ type RosaControlPlaneStatus struct {
454473
FailureMessage *string `json:"failureMessage,omitempty"`
455474
// Conditions specifies the cpnditions for the managed control plane
456475
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
476+
477+
// ID is the cluster ID given by ROSA.
478+
ID *string `json:"id,omitempty"`
457479
}
458480

459481
// +kubebuilder:object:root=true

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

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

0 commit comments

Comments
 (0)