Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ ROSA machinePools support #4725

Merged
merged 5 commits into from
Jan 17, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ spec:
type: object
creatorARN:
type: string
credentialsSecretRef:
description: 'CredentialsSecretRef references a secret with necessary
credentials to connect to the OCM API. The secret should contain
the following data keys: - ocmToken: eyJhbGciOiJIUzI1NiIsI.... -
ocmApiUrl: Optional, defaults to ''https://api.openshift.com'''
properties:
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
type: object
x-kubernetes-map-type: atomic
installerRoleARN:
type: string
machineCIDR:
Expand Down Expand Up @@ -237,6 +249,17 @@ spec:
- nodePoolManagementARN
- storageARN
type: object
rosaClusterName:
description: Cluster name must be valid DNS-1035 label, so it must
consist of lower case alphanumeric characters or '-', start with
an alphabetic character, end with an alphanumeric character and
have a max length of 15 characters.
maxLength: 15
pattern: ^[a-z]([-a-z0-9]*[a-z0-9])?$
type: string
x-kubernetes-validations:
- message: rosaClusterName is immutable
rule: self == oldSelf
subnets:
description: The Subnet IDs to use when installing the cluster. SubnetIDs
should come in pairs; two per availability zone, one private and
Expand All @@ -249,6 +272,8 @@ spec:
version:
description: Openshift version, for example "openshift-v4.12.15".
type: string
workerRoleARN:
type: string
required:
- accountID
- availabilityZones
Expand All @@ -258,9 +283,11 @@ spec:
- oidcID
- region
- rolesRef
- rosaClusterName
- subnets
- supportRoleARN
- version
- workerRoleARN
type: object
status:
properties:
Expand Down Expand Up @@ -320,6 +347,9 @@ spec:
description: ErrorMessage indicates that there is a terminal problem
reconciling the state, and will be set to a descriptive error message.
type: string
id:
description: ID is the cluster ID given by ROSA.
type: string
initialized:
description: Initialized denotes whether or not the control plane
has the uploaded kubernetes config-map.
Expand Down
168 changes: 168 additions & 0 deletions config/crd/bases/infrastructure.cluster.x-k8s.io_rosamachinepools.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.12.1
name: rosamachinepools.infrastructure.cluster.x-k8s.io
spec:
group: infrastructure.cluster.x-k8s.io
names:
categories:
- cluster-api
kind: ROSAMachinePool
listKind: ROSAMachinePoolList
plural: rosamachinepools
shortNames:
- rosamp
singular: rosamachinepool
scope: Namespaced
versions:
- additionalPrinterColumns:
- description: MachinePool ready status
jsonPath: .status.ready
name: Ready
type: string
- description: Number of replicas
jsonPath: .status.replicas
name: Replicas
type: integer
name: v1beta2
schema:
openAPIV3Schema:
description: ROSAMachinePool is the Schema for the rosamachinepools API.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: RosaMachinePoolSpec defines the desired state of RosaMachinePool.
properties:
autoRepair:
default: false
description: AutoRepair specifies whether health checks should be
enabled for machines in the NodePool. The default is false.
type: boolean
autoscaling:
description: Autoscaling specifies auto scaling behaviour for this
MachinePool. required if Replicas is not configured
properties:
maxReplicas:
minimum: 1
type: integer
minReplicas:
minimum: 1
type: integer
type: object
availabilityZone:
description: AvailabilityZone is an optinal field specifying the availability
zone where instances of this machine pool should run For Multi-AZ
clusters, you can create a machine pool in a Single-AZ of your choice.
type: string
instanceType:
description: InstanceType specifies the AWS instance type
type: string
labels:
additionalProperties:
type: string
description: Labels specifies labels for the Kubernetes node objects
type: object
nodePoolName:
description: NodePoolName specifies the name of the nodepool in Rosa
must be a valid DNS-1035 label, so it must consist of lower case
alphanumeric and have a max length of 15 characters.
maxLength: 15
pattern: ^[a-z]([-a-z0-9]*[a-z0-9])?$
type: string
x-kubernetes-validations:
- message: nodepoolName is immutable
rule: self == oldSelf
providerIDList:
description: ProviderIDList contain a ProviderID for each machine
instance that's currently managed by this machine pool.
items:
type: string
type: array
subnet:
type: string
required:
- nodePoolName
type: object
status:
description: RosaMachinePoolStatus defines the observed state of RosaMachinePool.
properties:
conditions:
description: Conditions defines current service state of the managed
machine pool
items:
description: Condition defines an observation of a Cluster API resource
operational state.
properties:
lastTransitionTime:
description: Last time the condition transitioned from one status
to another. This should be when the underlying condition changed.
If that is not known, then using the time when the API field
changed is acceptable.
format: date-time
type: string
message:
description: A human readable message indicating details about
the transition. This field may be empty.
type: string
reason:
description: The reason for the condition's last transition
in CamelCase. The specific API may choose whether or not this
field is considered a guaranteed API. This field may not be
empty.
type: string
severity:
description: Severity provides an explicit classification of
Reason code, so the users or machines can immediately understand
the current situation and act accordingly. The Severity field
MUST be set only when Status=False.
type: string
status:
description: Status of the condition, one of True, False, Unknown.
type: string
type:
description: Type of condition in CamelCase or in foo.example.com/CamelCase.
Many .condition.type values are consistent across resources
like Available, but because arbitrary conditions can be useful
(see .node.status.conditions), the ability to deconflict is
important.
type: string
required:
- lastTransitionTime
- status
- type
type: object
type: array
id:
description: ID is the ID given by ROSA.
type: string
ready:
default: false
description: Ready denotes that the RosaMachinePool nodepool has joined
the cluster
type: boolean
replicas:
description: Replicas is the most recently observed number of replicas.
format: int32
type: integer
required:
- ready
type: object
type: object
served: true
storage: true
subresources:
status: {}
1 change: 1 addition & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ resources:
- bases/bootstrap.cluster.x-k8s.io_eksconfigtemplates.yaml
- bases/controlplane.cluster.x-k8s.io_rosacontrolplanes.yaml
- bases/infrastructure.cluster.x-k8s.io_rosaclusters.yaml
- bases/infrastructure.cluster.x-k8s.io_rosamachinepools.yaml
# +kubebuilder:scaffold:crdkustomizeresource

patchesStrategicMerge:
Expand Down
19 changes: 19 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -378,3 +378,22 @@ rules:
- get
- patch
- update
- apiGroups:
- infrastructure.cluster.x-k8s.io
resources:
- rosamachinenepools
verbs:
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- infrastructure.cluster.x-k8s.io
resources:
- rosamachinenepools/status
verbs:
- get
- patch
- update
24 changes: 24 additions & 0 deletions controlplane/rosa/api/v1beta2/conditions_consts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Copyright 2022 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1beta2

import clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"

const (
// ROSAControlPlaneReadyCondition condition reports on the successful reconciliation of ROSAControlPlane.
ROSAControlPlaneReadyCondition clusterv1.ConditionType = "ROSAControlPlaneReady"
)
22 changes: 22 additions & 0 deletions controlplane/rosa/api/v1beta2/rosacontrolplane_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,23 @@ limitations under the License.
package v1beta2

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

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

type RosaControlPlaneSpec struct { //nolint: maligned
// Cluster name must be valid DNS-1035 label, so it must consist of lower case alphanumeric
// characters or '-', start with an alphabetic character, end with an alphanumeric character
// and have a max length of 15 characters.
//
// +immutable
// +kubebuilder:validation:XValidation:rule="self == oldSelf", message="rosaClusterName is immutable"
// +kubebuilder:validation:MaxLength:=15
// +kubebuilder:validation:Pattern:=`^[a-z]([-a-z0-9]*[a-z0-9])?$`
RosaClusterName string `json:"rosaClusterName"`

// The Subnet IDs to use when installing the cluster.
// SubnetIDs should come in pairs; two per availability zone, one private and one public.
Subnets []string `json:"subnets"`
Expand Down Expand Up @@ -55,6 +66,14 @@ type RosaControlPlaneSpec struct { //nolint: maligned
CreatorARN *string `json:"creatorARN"`
InstallerRoleARN *string `json:"installerRoleARN"`
SupportRoleARN *string `json:"supportRoleARN"`
WorkerRoleARN *string `json:"workerRoleARN"`

// CredentialsSecretRef references a secret with necessary credentials to connect to the OCM API.
// The secret should contain the following data keys:
// - ocmToken: eyJhbGciOiJIUzI1NiIsI....
// - ocmApiUrl: Optional, defaults to 'https://api.openshift.com'
// +optional
CredentialsSecretRef *corev1.LocalObjectReference `json:"credentialsSecretRef,omitempty"`
}

// AWSRolesRef contains references to various AWS IAM roles required for operators to make calls against the AWS API.
Expand Down Expand Up @@ -454,6 +473,9 @@ type RosaControlPlaneStatus struct {
FailureMessage *string `json:"failureMessage,omitempty"`
// Conditions specifies the cpnditions for the managed control plane
Conditions clusterv1.Conditions `json:"conditions,omitempty"`

// ID is the cluster ID given by ROSA.
ID *string `json:"id,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
16 changes: 16 additions & 0 deletions controlplane/rosa/api/v1beta2/zz_generated.deepcopy.go

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

Loading