Skip to content

Commit df597f3

Browse files
committed
add support for enabling ExternalAuthProviders on cluster creation
1 parent ad71a54 commit df597f3

File tree

3 files changed

+50
-29
lines changed

3 files changed

+50
-29
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@ spec:
144144
x-kubernetes-validations:
145145
- message: domainPrefix is immutable
146146
rule: self == oldSelf
147+
enableExternalAuthProviders:
148+
default: false
149+
description: EnableExternalAuthProviders enables external authentication
150+
configuration for the cluster.
151+
type: boolean
152+
x-kubernetes-validations:
153+
- message: enableExternalAuthProviders is immutable
154+
rule: self == oldSelf
147155
endpointAccess:
148156
default: Public
149157
description: EndpointAccess specifies the publishing scope of cluster
@@ -213,8 +221,11 @@ spec:
213221
type: string
214222
type: object
215223
oidcID:
216-
description: The ID of the OpenID Connect Provider.
224+
description: The ID of the internal OpenID Connect Provider.
217225
type: string
226+
x-kubernetes-validations:
227+
- message: oidcID is immutable
228+
rule: self == oldSelf
218229
provisionShardID:
219230
description: ProvisionShardID defines the shard where rosa control
220231
plane components will be hosted.

controlplane/rosa/api/v1beta2/rosacontrolplane_types.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,18 @@ type RosaControlPlaneSpec struct { //nolint: maligned
8080
// AWS IAM roles used to perform credential requests by the openshift operators.
8181
RolesRef AWSRolesRef `json:"rolesRef"`
8282

83-
// The ID of the OpenID Connect Provider.
83+
// The ID of the internal OpenID Connect Provider.
84+
//
85+
// +kubebuilder:validation:XValidation:rule="self == oldSelf", message="oidcID is immutable"
8486
OIDCID string `json:"oidcID"`
8587

88+
// EnableExternalAuthProviders enables external authentication configuration for the cluster.
89+
//
90+
// +kubebuilder:default=false
91+
// +kubebuilder:validation:XValidation:rule="self == oldSelf", message="enableExternalAuthProviders is immutable"
92+
// +optional
93+
EnableExternalAuthProviders bool `json:"enableExternalAuthProviders,omitempty"`
94+
8695
// InstallerRoleARN is an AWS IAM role that OpenShift Cluster Manager will assume to create the cluster..
8796
InstallerRoleARN string `json:"installerRoleARN"`
8897
// SupportRoleARN is an AWS IAM role used by Red Hat SREs to enable

controlplane/rosa/controllers/rosacontrolplane_controller.go

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -538,50 +538,51 @@ func validateControlPlaneSpec(ocmClient *ocm.Client, rosaScope *scope.ROSAContro
538538
return "", nil
539539
}
540540

541-
func buildOCMClusterSpec(controPlaneSpec rosacontrolplanev1.RosaControlPlaneSpec, creator *rosaaws.Creator) (ocm.Spec, error) {
542-
billingAccount := controPlaneSpec.BillingAccount
541+
func buildOCMClusterSpec(controlPlaneSpec rosacontrolplanev1.RosaControlPlaneSpec, creator *rosaaws.Creator) (ocm.Spec, error) {
542+
billingAccount := controlPlaneSpec.BillingAccount
543543
if billingAccount == "" {
544544
billingAccount = creator.AccountID
545545
}
546546

547547
ocmClusterSpec := ocm.Spec{
548548
DryRun: ptr.To(false),
549-
Name: controPlaneSpec.RosaClusterName,
550-
DomainPrefix: controPlaneSpec.DomainPrefix,
551-
Region: controPlaneSpec.Region,
549+
Name: controlPlaneSpec.RosaClusterName,
550+
DomainPrefix: controlPlaneSpec.DomainPrefix,
551+
Region: controlPlaneSpec.Region,
552552
MultiAZ: true,
553-
Version: ocm.CreateVersionID(controPlaneSpec.Version, ocm.DefaultChannelGroup),
553+
Version: ocm.CreateVersionID(controlPlaneSpec.Version, ocm.DefaultChannelGroup),
554554
ChannelGroup: ocm.DefaultChannelGroup,
555555
DisableWorkloadMonitoring: ptr.To(true),
556556
DefaultIngress: ocm.NewDefaultIngressSpec(), // n.b. this is a no-op when it's set to the default value
557-
ComputeMachineType: controPlaneSpec.DefaultMachinePoolSpec.InstanceType,
558-
AvailabilityZones: controPlaneSpec.AvailabilityZones,
559-
Tags: controPlaneSpec.AdditionalTags,
560-
EtcdEncryption: controPlaneSpec.EtcdEncryptionKMSARN != "",
561-
EtcdEncryptionKMSArn: controPlaneSpec.EtcdEncryptionKMSARN,
557+
ComputeMachineType: controlPlaneSpec.DefaultMachinePoolSpec.InstanceType,
558+
AvailabilityZones: controlPlaneSpec.AvailabilityZones,
559+
Tags: controlPlaneSpec.AdditionalTags,
560+
EtcdEncryption: controlPlaneSpec.EtcdEncryptionKMSARN != "",
561+
EtcdEncryptionKMSArn: controlPlaneSpec.EtcdEncryptionKMSARN,
562562

563-
SubnetIds: controPlaneSpec.Subnets,
563+
SubnetIds: controlPlaneSpec.Subnets,
564564
IsSTS: true,
565-
RoleARN: controPlaneSpec.InstallerRoleARN,
566-
SupportRoleARN: controPlaneSpec.SupportRoleARN,
567-
WorkerRoleARN: controPlaneSpec.WorkerRoleARN,
568-
OperatorIAMRoles: operatorIAMRoles(controPlaneSpec.RolesRef),
569-
OidcConfigId: controPlaneSpec.OIDCID,
565+
RoleARN: controlPlaneSpec.InstallerRoleARN,
566+
SupportRoleARN: controlPlaneSpec.SupportRoleARN,
567+
WorkerRoleARN: controlPlaneSpec.WorkerRoleARN,
568+
OperatorIAMRoles: operatorIAMRoles(controlPlaneSpec.RolesRef),
569+
OidcConfigId: controlPlaneSpec.OIDCID,
570570
Mode: "auto",
571571
Hypershift: ocm.Hypershift{
572572
Enabled: true,
573573
},
574-
BillingAccount: billingAccount,
575-
AWSCreator: creator,
576-
AuditLogRoleARN: ptr.To(controPlaneSpec.AuditLogRoleARN),
574+
BillingAccount: billingAccount,
575+
AWSCreator: creator,
576+
AuditLogRoleARN: ptr.To(controlPlaneSpec.AuditLogRoleARN),
577+
ExternalAuthProvidersEnabled: controlPlaneSpec.EnableExternalAuthProviders,
577578
}
578579

579-
if controPlaneSpec.EndpointAccess == rosacontrolplanev1.Private {
580+
if controlPlaneSpec.EndpointAccess == rosacontrolplanev1.Private {
580581
ocmClusterSpec.Private = ptr.To(true)
581582
ocmClusterSpec.PrivateLink = ptr.To(true)
582583
}
583584

584-
if networkSpec := controPlaneSpec.Network; networkSpec != nil {
585+
if networkSpec := controlPlaneSpec.Network; networkSpec != nil {
585586
if networkSpec.MachineCIDR != "" {
586587
_, machineCIDR, err := net.ParseCIDR(networkSpec.MachineCIDR)
587588
if err != nil {
@@ -612,17 +613,17 @@ func buildOCMClusterSpec(controPlaneSpec rosacontrolplanev1.RosaControlPlaneSpec
612613

613614
// Set cluster compute autoscaling replicas
614615
// In case autoscaling is not defined and multiple zones defined, set the compute nodes equal to the zones count.
615-
if computeAutoscaling := controPlaneSpec.DefaultMachinePoolSpec.Autoscaling; computeAutoscaling != nil {
616+
if computeAutoscaling := controlPlaneSpec.DefaultMachinePoolSpec.Autoscaling; computeAutoscaling != nil {
616617
ocmClusterSpec.Autoscaling = true
617618
ocmClusterSpec.MaxReplicas = computeAutoscaling.MaxReplicas
618619
ocmClusterSpec.MinReplicas = computeAutoscaling.MinReplicas
619-
} else if computeAutoscaling == nil && len(controPlaneSpec.AvailabilityZones) > 1 {
620-
ocmClusterSpec.ComputeNodes = len(controPlaneSpec.AvailabilityZones)
620+
} else if len(controlPlaneSpec.AvailabilityZones) > 1 {
621+
ocmClusterSpec.ComputeNodes = len(controlPlaneSpec.AvailabilityZones)
621622
}
622623

623-
if controPlaneSpec.ProvisionShardID != "" {
624+
if controlPlaneSpec.ProvisionShardID != "" {
624625
ocmClusterSpec.CustomProperties = map[string]string{
625-
"provision_shard_id": controPlaneSpec.ProvisionShardID,
626+
"provision_shard_id": controlPlaneSpec.ProvisionShardID,
626627
}
627628
}
628629

0 commit comments

Comments
 (0)