Skip to content

Commit bf714d8

Browse files
rosacontrolplane: support a separate billing account
Signed-off-by: Steve Kuznetsov <[email protected]>
1 parent ddc3065 commit bf714d8

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ spec:
5151
items:
5252
type: string
5353
type: array
54+
billingAccount:
55+
description: BillingAccount is an optional AWS account to use for
56+
billing the subscription fees for ROSA clusters. The cost of running
57+
each ROSA cluster will be billed to the infrastructure account in
58+
which the cluster is running.
59+
type: string
60+
x-kubernetes-validations:
61+
- message: billingAccount is immutable
62+
rule: self == oldSelf
63+
- message: billingAccount must be a valid AWS account ID
64+
rule: self.matches('^[0-9]{12}$')
5465
controlPlaneEndpoint:
5566
description: ControlPlaneEndpoint represents the endpoint used to
5667
communicate with the control plane.

controlplane/rosa/api/v1beta2/rosacontrolplane_types.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ type RosaControlPlaneSpec struct { //nolint: maligned
6868
SupportRoleARN *string `json:"supportRoleARN"`
6969
WorkerRoleARN *string `json:"workerRoleARN"`
7070

71+
// +immutable
72+
// +kubebuilder:validation:Optional
73+
// +kubebuilder:validation:XValidation:rule="self == oldSelf", message="billingAccount is immutable"
74+
// +kubebuilder:validation:XValidation:rule="self.matches('^[0-9]{12}$')", message="billingAccount must be a valid AWS account ID"
75+
76+
// BillingAccount is an optional AWS account to use for billing the subscription fees for ROSA clusters.
77+
// The cost of running each ROSA cluster will be billed to the infrastructure account in which the cluster
78+
// is running.
79+
BillingAccount string `json:"billingAccount,omitempty"`
80+
7181
// CredentialsSecretRef references a secret with necessary credentials to connect to the OCM API.
7282
// The secret should contain the following data keys:
7383
// - ocmToken: eyJhbGciOiJIUzI1NiIsI....

controlplane/rosa/controllers/rosacontrolplane_controller.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func (r *ROSAControlPlaneReconciler) reconcileNormal(ctx context.Context, rosaSc
200200
}
201201

202202
if validationMessage, validationError := validateControlPlaneSpec(ocmClient, rosaScope); validationError != nil {
203-
return ctrl.Result{}, fmt.Errorf("validate ROSAControlPlane.spec: %w", err)
203+
return ctrl.Result{}, fmt.Errorf("validate ROSAControlPlane.spec: %w", validationError)
204204
} else if validationMessage != "" {
205205
rosaScope.ControlPlane.Status.FailureMessage = ptr.To(validationMessage)
206206
// dont' requeue because input is invalid and manual intervention is needed.
@@ -268,14 +268,21 @@ func (r *ROSAControlPlaneReconciler) reconcileNormal(ctx context.Context, rosaSc
268268
rosaScope.Error(err, "rosacontrolplane.spec.machineCIDR invalid")
269269
}
270270

271+
billingAccount := *rosaScope.Identity.Account
272+
if rosaScope.ControlPlane.Spec.BillingAccount != "" {
273+
billingAccount = rosaScope.ControlPlane.Spec.BillingAccount
274+
}
275+
271276
spec := ocm.Spec{
277+
DryRun: ptr.To(false),
272278
Name: rosaScope.RosaClusterName(),
273279
Region: *rosaScope.ControlPlane.Spec.Region,
274280
MultiAZ: true,
275281
Version: ocm.CreateVersionID(rosaScope.ControlPlane.Spec.Version, ocm.DefaultChannelGroup),
276282
ChannelGroup: "stable",
277283
Expiration: time.Now().Add(1 * time.Hour),
278284
DisableWorkloadMonitoring: ptr.To(true),
285+
DefaultIngress: ocm.NewDefaultIngressSpec(), // n.b. this is a no-op when it's set to the default value
279286

280287
SubnetIds: rosaScope.ControlPlane.Spec.Subnets,
281288
AvailabilityZones: rosaScope.ControlPlane.Spec.AvailabilityZones,
@@ -332,7 +339,7 @@ func (r *ROSAControlPlaneReconciler) reconcileNormal(ctx context.Context, rosaSc
332339
Hypershift: ocm.Hypershift{
333340
Enabled: true,
334341
},
335-
BillingAccount: *rosaScope.Identity.Account,
342+
BillingAccount: billingAccount,
336343
AWSCreator: creator,
337344
}
338345

0 commit comments

Comments
 (0)