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: Reconcile ROSAMachinePool fields #4804

Merged
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 @@ -341,9 +341,6 @@ spec:
version:
description: OpenShift semantic version, for example "4.14.5".
type: string
x-kubernetes-validations:
- message: version must be a valid semantic version
rule: self.matches('^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$')
workerRoleARN:
type: string
required:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,48 @@ spec:
type: array
subnet:
type: string
x-kubernetes-validations:
- message: subnet is immutable
rule: self == oldSelf
taints:
description: Taints specifies the taints to apply to the nodes of
the machine pool
items:
properties:
effect:
description: The effect of the taint on pods that do not tolerate
the taint. Valid effects are NoSchedule, PreferNoSchedule
and NoExecute.
enum:
- NoSchedule
- PreferNoSchedule
- NoExecute
type: string
key:
description: The taint key to be applied to a node.
type: string
value:
description: The taint value corresponding to the taint key.
pattern: ^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$
type: string
required:
- effect
- key
type: object
type: array
tuningConfigs:
description: TuningConfigs specifies the names of the tuning configs
to be applied to this MachinePool. Tuning configs must already exist.
items:
type: string
type: array
version:
description: Version specifies the penshift version of the nodes associated
with this machinepool. ROSAControlPlane version is used if not set.
description: Version specifies the OpenShift version of the nodes
associated with this machinepool. ROSAControlPlane version is used
if not set.
type: string
x-kubernetes-validations:
- message: version must be a valid semantic version
rule: self.matches('^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$')
required:
- instanceType
- nodePoolName
type: object
status:
Expand Down
12 changes: 12 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ rules:
- get
- list
- watch
- apiGroups:
- controlplane.cluster.x-k8s.io
resources:
- rosacontrolplanes/finalizers
verbs:
- update
- apiGroups:
- controlplane.cluster.x-k8s.io
resources:
Expand Down Expand Up @@ -409,6 +415,12 @@ rules:
- patch
- update
- watch
- apiGroups:
- infrastructure.cluster.x-k8s.io
resources:
- rosamachinepools/finalizers
verbs:
- update
- apiGroups:
- infrastructure.cluster.x-k8s.io
resources:
Expand Down
88 changes: 88 additions & 0 deletions config/webhook/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,28 @@ webhooks:
resources:
- awsmanagedmachinepools
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: webhook-service
namespace: system
path: /mutate-infrastructure-cluster-x-k8s-io-v1beta2-rosamachinepool
failurePolicy: Fail
matchPolicy: Equivalent
name: default.rosamachinepool.infrastructure.cluster.x-k8s.io
rules:
- apiGroups:
- infrastructure.cluster.x-k8s.io
apiVersions:
- v1beta2
operations:
- CREATE
- UPDATE
resources:
- rosamachinepools
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
Expand Down Expand Up @@ -267,6 +289,28 @@ webhooks:
resources:
- awsmanagedcontrolplanes
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: webhook-service
namespace: system
path: /mutate-controlplane-cluster-x-k8s-io-v1beta2-rosacontrolplane
failurePolicy: Fail
matchPolicy: Equivalent
name: default.rosacontrolplanes.controlplane.cluster.x-k8s.io
rules:
- apiGroups:
- controlplane.cluster.x-k8s.io
apiVersions:
- v1beta2
operations:
- CREATE
- UPDATE
resources:
- rosacontrolplanes
sideEffects: None
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
Expand Down Expand Up @@ -493,6 +537,28 @@ webhooks:
resources:
- awsmanagedmachinepools
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: webhook-service
namespace: system
path: /validate-infrastructure-cluster-x-k8s-io-v1beta2-rosamachinepool
failurePolicy: Fail
matchPolicy: Equivalent
name: validation.rosamachinepool.infrastructure.cluster.x-k8s.io
rules:
- apiGroups:
- infrastructure.cluster.x-k8s.io
apiVersions:
- v1beta2
operations:
- CREATE
- UPDATE
resources:
- rosamachinepools
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
Expand Down Expand Up @@ -559,3 +625,25 @@ webhooks:
resources:
- awsmanagedcontrolplanes
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: webhook-service
namespace: system
path: /validate-controlplane-cluster-x-k8s-io-v1beta2-rosacontrolplane
failurePolicy: Fail
matchPolicy: Equivalent
name: validation.rosacontrolplanes.controlplane.cluster.x-k8s.io
rules:
- apiGroups:
- controlplane.cluster.x-k8s.io
apiVersions:
- v1beta2
operations:
- CREATE
- UPDATE
resources:
- rosacontrolplanes
sideEffects: None
9 changes: 9 additions & 0 deletions controlplane/rosa/api/v1beta2/conditions_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ const (
// ROSAControlPlaneReadyCondition condition reports on the successful reconciliation of ROSAControlPlane.
ROSAControlPlaneReadyCondition clusterv1.ConditionType = "ROSAControlPlaneReady"

// ROSAControlPlaneValidCondition condition reports whether ROSAControlPlane configuration is valid.
ROSAControlPlaneValidCondition clusterv1.ConditionType = "ROSAControlPlaneValid"

// ROSAControlPlaneUpgradingCondition condition reports whether ROSAControlPlane is upgrading or not.
ROSAControlPlaneUpgradingCondition clusterv1.ConditionType = "ROSAControlPlaneUpgrading"

// ROSAControlPlaneReconciliationFailedReason used to report failures while reconciling ROSAControlPlane.
ROSAControlPlaneReconciliationFailedReason = "ReconciliationFailed"

// ROSAControlPlaneInvalidConfigurationReason used to report invalid user input.
ROSAControlPlaneInvalidConfigurationReason = "InvalidConfiguration"
)
35 changes: 19 additions & 16 deletions controlplane/rosa/api/v1beta2/rosacontrolplane_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ type RosaControlPlaneSpec struct { //nolint: maligned
// 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])?$`
// +immutable
RosaClusterName string `json:"rosaClusterName"`

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

// The AWS Region the cluster lives in.
Region *string `json:"region"`
Region string `json:"region"`

// OpenShift semantic version, for example "4.14.5".
// +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"
Version string `json:"version"`

// ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
// +optional
ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"`

// AWS IAM roles used to perform credential requests by the openshift operators.
RolesRef AWSRolesRef `json:"rolesRef"`

// The ID of the OpenID Connect Provider.
OIDCID *string `json:"oidcID"`
OIDCID string `json:"oidcID"`

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

// +immutable
// +kubebuilder:validation:Optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf", message="billingAccount is immutable"
// +kubebuilder:validation:XValidation:rule="self.matches('^[0-9]{12}$')", message="billingAccount must be a valid AWS account ID"

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

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

// +optional

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

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

// The instance type to use, for example `r5.xlarge`. Instance type ref; https://aws.amazon.com/ec2/instance-types/
Expand All @@ -99,12 +96,17 @@ type RosaControlPlaneSpec struct { //nolint: maligned
// Autoscaling specifies auto scaling behaviour for the MachinePools.
// +optional
Autoscaling *expinfrav1.RosaMachinePoolAutoScaling `json:"autoscaling,omitempty"`

// ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
// +optional
ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"`
}

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

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

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

// ID is the cluster ID given by ROSA.
ID *string `json:"id,omitempty"`
ID string `json:"id,omitempty"`
// ConsoleURL is the url for the openshift console.
ConsoleURL string `json:"consoleURL,omitempty"`
// OIDCEndpointURL is the endpoint url for the managed OIDC porvider.
Expand Down
Loading