Skip to content

Commit bb670aa

Browse files
Merge pull request #1458 from dharaneeshvrd/powervs-ingress
Add PowerVS Ingress Operator Changes
2 parents 624dab0 + a47abed commit bb670aa

File tree

12 files changed

+191
-2
lines changed

12 files changed

+191
-2
lines changed

api/fixtures/example.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ web_identity_token_file = /var/run/secrets/openshift/serviceaccount/token
438438
buildIBMCloudCreds(o.Name+"-cloud-ctrl-creds", o.PowerVS.ApiKey),
439439
buildIBMCloudCreds(o.Name+"-node-mgmt-creds", o.PowerVS.ApiKey),
440440
buildIBMCloudCreds(o.Name+"-cpo-creds", o.PowerVS.ApiKey),
441+
buildIBMCloudCreds(o.Name+"-ingress-creds", o.PowerVS.ApiKey),
441442
}
442443
resources = powerVSResources.AsObjects()
443444
platformSpec = hyperv1.PlatformSpec{
@@ -447,6 +448,7 @@ web_identity_token_file = /var/run/secrets/openshift/serviceaccount/token
447448
ResourceGroup: o.PowerVS.ResourceGroup,
448449
Region: o.PowerVS.Region,
449450
Zone: o.PowerVS.Zone,
451+
CISInstanceCRN: o.PowerVS.CISInstanceCRN,
450452
ServiceInstanceID: o.PowerVS.CloudInstanceID,
451453
Subnet: &hyperv1.PowerVSResourceReference{
452454
Name: &o.PowerVS.Subnet,
@@ -460,6 +462,7 @@ web_identity_token_file = /var/run/secrets/openshift/serviceaccount/token
460462
KubeCloudControllerCreds: corev1.LocalObjectReference{Name: powerVSResources.KubeCloudControllerCreds.Name},
461463
NodePoolManagementCreds: corev1.LocalObjectReference{Name: powerVSResources.NodePoolManagementCreds.Name},
462464
ControlPlaneOperatorCreds: corev1.LocalObjectReference{Name: powerVSResources.ControlPlaneOperatorCreds.Name},
465+
IngressOperatorCloudCreds: corev1.LocalObjectReference{Name: powerVSResources.IngressOperatorCloudCreds.Name},
463466
},
464467
}
465468
services = getIngressServicePublishingStrategyMapping(o.NetworkType)

api/fixtures/example_ibmcloud_powervs.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ type ExamplePowerVSOptions struct {
1111
ResourceGroup string
1212
Region string
1313
Zone string
14+
CISInstanceCRN string
1415
CloudInstanceID string
1516
Subnet string
1617
SubnetID string
@@ -30,6 +31,7 @@ type ExamplePowerVSResources struct {
3031
KubeCloudControllerCreds *corev1.Secret
3132
NodePoolManagementCreds *corev1.Secret
3233
ControlPlaneOperatorCreds *corev1.Secret
34+
IngressOperatorCloudCreds *corev1.Secret
3335
}
3436

3537
func (o *ExamplePowerVSResources) AsObjects() []crclient.Object {
@@ -43,5 +45,8 @@ func (o *ExamplePowerVSResources) AsObjects() []crclient.Object {
4345
if o.ControlPlaneOperatorCreds != nil {
4446
objects = append(objects, o.ControlPlaneOperatorCreds)
4547
}
48+
if o.IngressOperatorCloudCreds != nil {
49+
objects = append(objects, o.IngressOperatorCloudCreds)
50+
}
4651
return objects
4752
}

api/v1alpha1/hostedcluster_types.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,13 @@ type PowerVSPlatformSpec struct {
590590
// +immutable
591591
AccountID string `json:"accountID"`
592592

593+
// CISInstanceCRN is the IBMCloud CIS Service Instance's Cloud Resource Name
594+
// This field is immutable. Once set, It can't be changed.
595+
//
596+
// +kubebuilder:validation:Pattern=`^crn:`
597+
// +immutable
598+
CISInstanceCRN string `json:"cisInstanceCRN"`
599+
593600
// ResourceGroup is the IBMCloud Resource Group in which the cluster resides.
594601
// This field is immutable. Once set, It can't be changed.
595602
//
@@ -663,6 +670,12 @@ type PowerVSPlatformSpec struct {
663670
//
664671
// +immutable
665672
ControlPlaneOperatorCreds corev1.LocalObjectReference `json:"controlPlaneOperatorCreds"`
673+
674+
// IngressOperatorCloudCreds is a reference to a secret containing ibm cloud
675+
// credentials for ingress operator to get authenticated with ibm cloud.
676+
//
677+
// +immutable
678+
IngressOperatorCloudCreds corev1.LocalObjectReference `json:"ingressOperatorCloudCreds"`
666679
}
667680

668681
// PowerVSVPC specifies IBM Cloud PowerVS LoadBalancer configuration for the control

api/v1alpha1/zz_generated.deepcopy.go

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

cmd/cluster/powervs/create.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ func applyPlatformSpecificsValues(ctx context.Context, exampleOptions *apifixtur
157157
ResourceGroup: opts.PowerVSPlatform.ResourceGroup,
158158
Region: opts.PowerVSPlatform.Region,
159159
Zone: opts.PowerVSPlatform.Zone,
160+
CISInstanceCRN: infra.CisCrn,
160161
CloudInstanceID: infra.PowerVSCloudInstanceID,
161162
Subnet: infra.PowerVSDhcpSubnet,
162163
SubnetID: infra.PowerVSDhcpSubnetID,

cmd/install/assets/hypershift-operator/hypershift.openshift.io_hostedclusters.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,6 +2339,12 @@ spec:
23392339
description: AccountID is the IBMCloud account id. This field
23402340
is immutable. Once set, It can't be changed.
23412341
type: string
2342+
cisInstanceCRN:
2343+
description: CISInstanceCRN is the IBMCloud CIS Service Instance's
2344+
Cloud Resource Name This field is immutable. Once set, It
2345+
can't be changed.
2346+
pattern: '^crn:'
2347+
type: string
23422348
controlPlaneOperatorCreds:
23432349
description: "ControlPlaneOperatorCreds is a reference to
23442350
a secret containing cloud credentials with permissions matching
@@ -2351,6 +2357,16 @@ spec:
23512357
TODO: Add other useful fields. apiVersion, kind, uid?'
23522358
type: string
23532359
type: object
2360+
ingressOperatorCloudCreds:
2361+
description: IngressOperatorCloudCreds is a reference to a
2362+
secret containing ibm cloud credentials for ingress operator
2363+
to get authenticated with ibm cloud.
2364+
properties:
2365+
name:
2366+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
2367+
TODO: Add other useful fields. apiVersion, kind, uid?'
2368+
type: string
2369+
type: object
23542370
kubeCloudControllerCreds:
23552371
description: "KubeCloudControllerCreds is a reference to a
23562372
secret containing cloud credentials with permissions matching
@@ -2446,7 +2462,9 @@ spec:
24462462
type: string
24472463
required:
24482464
- accountID
2465+
- cisInstanceCRN
24492466
- controlPlaneOperatorCreds
2467+
- ingressOperatorCloudCreds
24502468
- kubeCloudControllerCreds
24512469
- nodePoolManagementCreds
24522470
- region

cmd/install/assets/hypershift-operator/hypershift.openshift.io_hostedcontrolplanes.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2247,6 +2247,12 @@ spec:
22472247
description: AccountID is the IBMCloud account id. This field
22482248
is immutable. Once set, It can't be changed.
22492249
type: string
2250+
cisInstanceCRN:
2251+
description: CISInstanceCRN is the IBMCloud CIS Service Instance's
2252+
Cloud Resource Name This field is immutable. Once set, It
2253+
can't be changed.
2254+
pattern: '^crn:'
2255+
type: string
22502256
controlPlaneOperatorCreds:
22512257
description: "ControlPlaneOperatorCreds is a reference to
22522258
a secret containing cloud credentials with permissions matching
@@ -2259,6 +2265,16 @@ spec:
22592265
TODO: Add other useful fields. apiVersion, kind, uid?'
22602266
type: string
22612267
type: object
2268+
ingressOperatorCloudCreds:
2269+
description: IngressOperatorCloudCreds is a reference to a
2270+
secret containing ibm cloud credentials for ingress operator
2271+
to get authenticated with ibm cloud.
2272+
properties:
2273+
name:
2274+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
2275+
TODO: Add other useful fields. apiVersion, kind, uid?'
2276+
type: string
2277+
type: object
22622278
kubeCloudControllerCreds:
22632279
description: "KubeCloudControllerCreds is a reference to a
22642280
secret containing cloud credentials with permissions matching
@@ -2354,7 +2370,9 @@ spec:
23542370
type: string
23552371
required:
23562372
- accountID
2373+
- cisInstanceCRN
23572374
- controlPlaneOperatorCreds
2375+
- ingressOperatorCloudCreds
23582376
- kubeCloudControllerCreds
23592377
- nodePoolManagementCreds
23602378
- region

control-plane-operator/hostedclusterconfigoperator/controllers/resources/resources.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,37 @@ func (r *reconciler) reconcileCloudCredentialSecrets(ctx context.Context, hcp *h
876876
}); err != nil {
877877
errs = append(errs, fmt.Errorf("failed to reconcile csi driver secret: %w", err))
878878
}
879+
case hyperv1.PowerVSPlatform:
880+
var ingressCredentials corev1.Secret
881+
err := r.cpClient.Get(ctx, client.ObjectKey{Namespace: hcp.Namespace, Name: hcp.Spec.Platform.PowerVS.IngressOperatorCloudCreds.Name}, &ingressCredentials)
882+
if err != nil {
883+
errs = append(errs, fmt.Errorf("failed to get ingress operator cloud credentials secret %s from hcp namespace : %w", hcp.Spec.Platform.PowerVS.IngressOperatorCloudCreds.Name, err))
884+
return errs
885+
}
886+
887+
cloudCredentials := &corev1.Secret{
888+
ObjectMeta: metav1.ObjectMeta{
889+
Namespace: "openshift-ingress-operator",
890+
Name: "cloud-credentials",
891+
},
892+
}
893+
894+
_, err = r.CreateOrUpdate(ctx, r.client, cloudCredentials, func() error {
895+
credData, credHasData := ingressCredentials.Data["ibmcloud_api_key"]
896+
if !credHasData {
897+
return fmt.Errorf("ingress cloud credentials secret %q is missing credentials key", ingressCredentials.Name)
898+
}
899+
cloudCredentials.Type = corev1.SecretTypeOpaque
900+
if cloudCredentials.Data == nil {
901+
cloudCredentials.Data = map[string][]byte{}
902+
}
903+
cloudCredentials.Data["ibmcloud_api_key"] = credData
904+
return nil
905+
})
906+
907+
if err != nil {
908+
errs = append(errs, fmt.Errorf("failed to reconcile powervs cloud credentials secret %w", err))
909+
}
879910
}
880911
return errs
881912
}

docs/content/reference/api.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5467,6 +5467,18 @@ This field is immutable. Once set, It can&rsquo;t be changed.</p>
54675467
</tr>
54685468
<tr>
54695469
<td>
5470+
<code>cisInstanceCRN</code></br>
5471+
<em>
5472+
string
5473+
</em>
5474+
</td>
5475+
<td>
5476+
<p>CISInstanceCRN is the IBMCloud CIS Service Instance&rsquo;s Cloud Resource Name
5477+
This field is immutable. Once set, It can&rsquo;t be changed.</p>
5478+
</td>
5479+
</tr>
5480+
<tr>
5481+
<td>
54705482
<code>resourceGroup</code></br>
54715483
<em>
54725484
string
@@ -5598,6 +5610,20 @@ This field is immutable. Once set, It can&rsquo;t be changed.</p>
55985610
<p>TODO(dan): document the &ldquo;control plane operator policy&rdquo;</p>
55995611
</td>
56005612
</tr>
5613+
<tr>
5614+
<td>
5615+
<code>ingressOperatorCloudCreds</code></br>
5616+
<em>
5617+
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#localobjectreference-v1-core">
5618+
Kubernetes core/v1.LocalObjectReference
5619+
</a>
5620+
</em>
5621+
</td>
5622+
<td>
5623+
<p>IngressOperatorCloudCreds is a reference to a secret containing ibm cloud
5624+
credentials for ingress operator to get authenticated with ibm cloud.</p>
5625+
</td>
5626+
</tr>
56015627
</tbody>
56025628
</table>
56035629
###PowerVSResourceReference { #hypershift.openshift.io/v1alpha1.PowerVSResourceReference }

hack/app-sre/saas_template.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22335,6 +22335,12 @@ objects:
2233522335
description: AccountID is the IBMCloud account id. This
2233622336
field is immutable. Once set, It can't be changed.
2233722337
type: string
22338+
cisInstanceCRN:
22339+
description: CISInstanceCRN is the IBMCloud CIS Service
22340+
Instance's Cloud Resource Name This field is immutable.
22341+
Once set, It can't be changed.
22342+
pattern: '^crn:'
22343+
type: string
2233822344
controlPlaneOperatorCreds:
2233922345
description: "ControlPlaneOperatorCreds is a reference to
2234022346
a secret containing cloud credentials with permissions
@@ -22347,6 +22353,16 @@ objects:
2234722353
TODO: Add other useful fields. apiVersion, kind, uid?'
2234822354
type: string
2234922355
type: object
22356+
ingressOperatorCloudCreds:
22357+
description: IngressOperatorCloudCreds is a reference to
22358+
a secret containing ibm cloud credentials for ingress
22359+
operator to get authenticated with ibm cloud.
22360+
properties:
22361+
name:
22362+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
22363+
TODO: Add other useful fields. apiVersion, kind, uid?'
22364+
type: string
22365+
type: object
2235022366
kubeCloudControllerCreds:
2235122367
description: "KubeCloudControllerCreds is a reference to
2235222368
a secret containing cloud credentials with permissions
@@ -22442,7 +22458,9 @@ objects:
2244222458
type: string
2244322459
required:
2244422460
- accountID
22461+
- cisInstanceCRN
2244522462
- controlPlaneOperatorCreds
22463+
- ingressOperatorCloudCreds
2244622464
- kubeCloudControllerCreds
2244722465
- nodePoolManagementCreds
2244822466
- region
@@ -25316,6 +25334,12 @@ objects:
2531625334
description: AccountID is the IBMCloud account id. This
2531725335
field is immutable. Once set, It can't be changed.
2531825336
type: string
25337+
cisInstanceCRN:
25338+
description: CISInstanceCRN is the IBMCloud CIS Service
25339+
Instance's Cloud Resource Name This field is immutable.
25340+
Once set, It can't be changed.
25341+
pattern: '^crn:'
25342+
type: string
2531925343
controlPlaneOperatorCreds:
2532025344
description: "ControlPlaneOperatorCreds is a reference to
2532125345
a secret containing cloud credentials with permissions
@@ -25328,6 +25352,16 @@ objects:
2532825352
TODO: Add other useful fields. apiVersion, kind, uid?'
2532925353
type: string
2533025354
type: object
25355+
ingressOperatorCloudCreds:
25356+
description: IngressOperatorCloudCreds is a reference to
25357+
a secret containing ibm cloud credentials for ingress
25358+
operator to get authenticated with ibm cloud.
25359+
properties:
25360+
name:
25361+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
25362+
TODO: Add other useful fields. apiVersion, kind, uid?'
25363+
type: string
25364+
type: object
2533125365
kubeCloudControllerCreds:
2533225366
description: "KubeCloudControllerCreds is a reference to
2533325367
a secret containing cloud credentials with permissions
@@ -25423,7 +25457,9 @@ objects:
2542325457
type: string
2542425458
required:
2542525459
- accountID
25460+
- cisInstanceCRN
2542625461
- controlPlaneOperatorCreds
25462+
- ingressOperatorCloudCreds
2542725463
- kubeCloudControllerCreds
2542825464
- nodePoolManagementCreds
2542925465
- region

0 commit comments

Comments
 (0)