Skip to content

Commit 3a00c39

Browse files
authored
Merge pull request #4844 from muraee/rosacontrolplane-new-fields
✨Add new fields to ROSAControlPlane - additionalTags, etcdEncryption, endpointAccess
2 parents f103bff + 87df892 commit 3a00c39

File tree

10 files changed

+1920
-161
lines changed

10 files changed

+1920
-161
lines changed

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ spec:
4747
spec:
4848
description: RosaControlPlaneSpec defines the desired state of ROSAControlPlane.
4949
properties:
50+
additionalTags:
51+
additionalProperties:
52+
type: string
53+
description: AdditionalTags are user-defined tags to be added on the
54+
AWS resources associated with the control plane.
55+
type: object
5056
autoscaling:
5157
description: Autoscaling specifies auto scaling behaviour for the
5258
MachinePools.
@@ -102,6 +108,19 @@ spec:
102108
type: string
103109
type: object
104110
x-kubernetes-map-type: atomic
111+
endpointAccess:
112+
default: Public
113+
description: EndpointAccess specifies the publishing scope of cluster
114+
endpoints. The default is Public.
115+
enum:
116+
- Public
117+
- Private
118+
type: string
119+
etcdEncryptionKMSArn:
120+
description: EtcdEncryptionKMSArn is the ARN of the KMS key used to
121+
encrypt etcd. The key itself needs to be created out-of-band by
122+
the user and tagged with `red-hat:true`.
123+
type: string
105124
identityRef:
106125
description: IdentityRef is a reference to an identity to be used
107126
when reconciling the managed control plane. If no identity is specified,
@@ -361,7 +380,7 @@ spec:
361380
description: RosaControlPlaneStatus defines the observed state of ROSAControlPlane.
362381
properties:
363382
conditions:
364-
description: Conditions specifies the cpnditions for the managed control
383+
description: Conditions specifies the conditions for the managed control
365384
plane
366385
items:
367386
description: Condition defines an observation of a Cluster API resource
@@ -433,7 +452,7 @@ spec:
433452
type: boolean
434453
oidcEndpointURL:
435454
description: OIDCEndpointURL is the endpoint url for the managed OIDC
436-
porvider.
455+
provider.
437456
type: string
438457
ready:
439458
default: false

controlplane/rosa/api/v1beta2/doc.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
Copyright 2024 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 contains API Schema definitions for the controlplane v1beta2 API group
18+
// +gencrdrefdocs:force
19+
// +groupName=controlplane.cluster.x-k8s.io
20+
// +k8s:defaulter-gen=TypeMeta
21+
package v1beta2

controlplane/rosa/api/v1beta2/rosacontrolplane_types.go

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ import (
2525
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2626
)
2727

28+
// RosaEndpointAccessType specifies the publishing scope of cluster endpoints.
29+
type RosaEndpointAccessType string
30+
31+
const (
32+
// Public endpoint access allows public API server access and
33+
// private node communication with the control plane.
34+
Public RosaEndpointAccessType = "Public"
35+
36+
// Private endpoint access allows only private API server access and private
37+
// node communication with the control plane.
38+
Private RosaEndpointAccessType = "Private"
39+
)
40+
2841
// RosaControlPlaneSpec defines the desired state of ROSAControlPlane.
2942
type RosaControlPlaneSpec struct { //nolint: maligned
3043
// Cluster name must be valid DNS-1035 label, so it must consist of lower case alphanumeric
@@ -90,6 +103,14 @@ type RosaControlPlaneSpec struct { //nolint: maligned
90103
// +optional
91104
Network *NetworkSpec `json:"network,omitempty"`
92105

106+
// EndpointAccess specifies the publishing scope of cluster endpoints. The
107+
// default is Public.
108+
//
109+
// +kubebuilder:validation:Enum=Public;Private
110+
// +kubebuilder:default=Public
111+
// +optional
112+
EndpointAccess RosaEndpointAccessType `json:"endpointAccess,omitempty"`
113+
93114
// The instance type to use, for example `r5.xlarge`. Instance type ref; https://aws.amazon.com/ec2/instance-types/
94115
// +optional
95116
InstanceType string `json:"instanceType,omitempty"`
@@ -98,6 +119,15 @@ type RosaControlPlaneSpec struct { //nolint: maligned
98119
// +optional
99120
Autoscaling *expinfrav1.RosaMachinePoolAutoScaling `json:"autoscaling,omitempty"`
100121

122+
// AdditionalTags are user-defined tags to be added on the AWS resources associated with the control plane.
123+
// +optional
124+
AdditionalTags infrav1.Tags `json:"additionalTags,omitempty"`
125+
126+
// EtcdEncryptionKMSArn is the ARN of the KMS key used to encrypt etcd. The key itself needs to be
127+
// created out-of-band by the user and tagged with `red-hat:true`.
128+
// +optional
129+
EtcdEncryptionKMSArn string `json:"etcdEncryptionKMSArn,omitempty"`
130+
101131
// ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
102132
// +optional
103133
ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"`
@@ -534,14 +564,14 @@ type RosaControlPlaneStatus struct {
534564
//
535565
// +optional
536566
FailureMessage *string `json:"failureMessage,omitempty"`
537-
// Conditions specifies the cpnditions for the managed control plane
567+
// Conditions specifies the conditions for the managed control plane
538568
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
539569

540570
// ID is the cluster ID given by ROSA.
541571
ID string `json:"id,omitempty"`
542572
// ConsoleURL is the url for the openshift console.
543573
ConsoleURL string `json:"consoleURL,omitempty"`
544-
// OIDCEndpointURL is the endpoint url for the managed OIDC porvider.
574+
// OIDCEndpointURL is the endpoint url for the managed OIDC provider.
545575
OIDCEndpointURL string `json:"oidcEndpointURL,omitempty"`
546576
}
547577

controlplane/rosa/api/v1beta2/rosacontrolplane_webhook.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"net"
55

66
"github.com/blang/semver"
7+
kmsArnRegexpValidator "github.com/openshift-online/ocm-common/pkg/resource/validations"
78
apierrors "k8s.io/apimachinery/pkg/api/errors"
89
runtime "k8s.io/apimachinery/pkg/runtime"
910
"k8s.io/apimachinery/pkg/util/validation/field"
@@ -33,7 +34,12 @@ func (r *ROSAControlPlane) ValidateCreate() (warnings admission.Warnings, err er
3334
allErrs = append(allErrs, err)
3435
}
3536

37+
if err := r.validateEtcdEncryptionKMSArn(); err != nil {
38+
allErrs = append(allErrs, err)
39+
}
40+
3641
allErrs = append(allErrs, r.validateNetwork()...)
42+
allErrs = append(allErrs, r.Spec.AdditionalTags.Validate()...)
3743

3844
if len(allErrs) == 0 {
3945
return nil, nil
@@ -54,7 +60,12 @@ func (r *ROSAControlPlane) ValidateUpdate(old runtime.Object) (warnings admissio
5460
allErrs = append(allErrs, err)
5561
}
5662

63+
if err := r.validateEtcdEncryptionKMSArn(); err != nil {
64+
allErrs = append(allErrs, err)
65+
}
66+
5767
allErrs = append(allErrs, r.validateNetwork()...)
68+
allErrs = append(allErrs, r.Spec.AdditionalTags.Validate()...)
5869

5970
if len(allErrs) == 0 {
6071
return nil, nil
@@ -113,6 +124,15 @@ func (r *ROSAControlPlane) validateNetwork() field.ErrorList {
113124
return allErrs
114125
}
115126

127+
func (r *ROSAControlPlane) validateEtcdEncryptionKMSArn() *field.Error {
128+
err := kmsArnRegexpValidator.ValidateKMSKeyARN(&r.Spec.EtcdEncryptionKMSArn)
129+
if err != nil {
130+
return field.Invalid(field.NewPath("spec.EtcdEncryptionKMSArn"), r.Spec.EtcdEncryptionKMSArn, err.Error())
131+
}
132+
133+
return nil
134+
}
135+
116136
// Default implements admission.Defaulter.
117137
func (r *ROSAControlPlane) Default() {
118138
SetObjectDefaults_ROSAControlPlane(r)

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

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

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

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

controlplane/rosa/controllers/rosacontrolplane_controller.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,12 @@ func (r *ROSAControlPlaneReconciler) reconcileNormal(ctx context.Context, rosaSc
280280
MultiAZ: true,
281281
Version: ocm.CreateVersionID(rosaScope.ControlPlane.Spec.Version, ocm.DefaultChannelGroup),
282282
ChannelGroup: ocm.DefaultChannelGroup,
283-
Expiration: time.Now().Add(1 * time.Hour),
284283
DisableWorkloadMonitoring: ptr.To(true),
285284
DefaultIngress: ocm.NewDefaultIngressSpec(), // n.b. this is a no-op when it's set to the default value
286285
ComputeMachineType: rosaScope.ControlPlane.Spec.InstanceType,
286+
Tags: rosaScope.ControlPlane.Spec.AdditionalTags,
287+
EtcdEncryption: rosaScope.ControlPlane.Spec.EtcdEncryptionKMSArn != "",
288+
EtcdEncryptionKMSArn: rosaScope.ControlPlane.Spec.EtcdEncryptionKMSArn,
287289

288290
SubnetIds: rosaScope.ControlPlane.Spec.Subnets,
289291
AvailabilityZones: rosaScope.ControlPlane.Spec.AvailabilityZones,
@@ -301,6 +303,11 @@ func (r *ROSAControlPlaneReconciler) reconcileNormal(ctx context.Context, rosaSc
301303
AWSCreator: creator,
302304
}
303305

306+
if rosaScope.ControlPlane.Spec.EndpointAccess == rosacontrolplanev1.Private {
307+
ocmClusterSpec.Private = ptr.To(true)
308+
ocmClusterSpec.PrivateLink = ptr.To(true)
309+
}
310+
304311
if networkSpec := rosaScope.ControlPlane.Spec.Network; networkSpec != nil {
305312
if networkSpec.MachineCIDR != "" {
306313
_, machineCIDR, err := net.ParseCIDR(networkSpec.MachineCIDR)

0 commit comments

Comments
 (0)