Skip to content

Commit 0abccb8

Browse files
committed
Use IBM COS as storage backend for PowerVS
1 parent 5c81c66 commit 0abccb8

16 files changed

+275
-17
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ require (
2727
github.com/gophercloud/utils v0.0.0-20221124081324-7bac6f5cdf99
2828
github.com/goware/urlx v0.3.2
2929
github.com/jongio/azidext/go/azidext v0.4.0
30-
github.com/openshift/api v0.0.0-20230210191657-68f4ffcda083
30+
github.com/openshift/api v0.0.0-20230213202419-42edf4f1d905
3131
github.com/openshift/build-machinery-go v0.0.0-20220913142420-e25cf57ea46d
3232
github.com/openshift/client-go v0.0.0-20230120202327-72f107311084
3333
github.com/openshift/library-go v0.0.0-20230120214501-9bc305884fcb

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,8 +589,8 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J
589589
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
590590
github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc=
591591
github.com/onsi/gomega v1.23.0 h1:/oxKu9c2HVap+F3PfKort2Hw5DEU+HGlW8n+tguWsys=
592-
github.com/openshift/api v0.0.0-20230210191657-68f4ffcda083 h1:Wc3z06B8JaEOnPlNovVB3ZR92CoSLWFupOeYO3khzCE=
593-
github.com/openshift/api v0.0.0-20230210191657-68f4ffcda083/go.mod h1:ctXNyWanKEjGj8sss1KjjHQ3ENKFm33FFnS5BKaIPh4=
592+
github.com/openshift/api v0.0.0-20230213202419-42edf4f1d905 h1:f+W57UXpRIJeZIh9lGLIPix/YxdFDBgHDGo0OkIgQw0=
593+
github.com/openshift/api v0.0.0-20230213202419-42edf4f1d905/go.mod h1:ctXNyWanKEjGj8sss1KjjHQ3ENKFm33FFnS5BKaIPh4=
594594
github.com/openshift/build-machinery-go v0.0.0-20220913142420-e25cf57ea46d h1:RR4ah7FfaPR1WePizm0jlrsbmPu91xQZnAsVVreQV1k=
595595
github.com/openshift/build-machinery-go v0.0.0-20220913142420-e25cf57ea46d/go.mod h1:b1BuldmJlbA/xYtdZvKi+7j5YGB44qJUJDZ9zwiNCfE=
596596
github.com/openshift/client-go v0.0.0-20230120202327-72f107311084 h1:66uaqNwA+qYyQDwsMWUfjjau8ezmg1dzCqub13KZOcE=
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apiVersion: cloudcredential.openshift.io/v1
2+
kind: CredentialsRequest
3+
metadata:
4+
labels:
5+
controller-tools.k8s.io: "1.0"
6+
name: openshift-image-registry-ibmcos-powervs
7+
namespace: openshift-cloud-credential-operator
8+
annotations:
9+
include.release.openshift.io/ibm-cloud-managed: "true"
10+
include.release.openshift.io/self-managed-high-availability: "true"
11+
include.release.openshift.io/single-node-developer: "true"
12+
spec:
13+
secretRef:
14+
name: installer-cloud-credentials
15+
namespace: openshift-image-registry
16+
providerSpec:
17+
apiVersion: cloudcredential.openshift.io/v1
18+
kind: IBMCloudPowerVSProviderSpec
19+
policies:
20+
- attributes:
21+
- name: serviceName
22+
value: cloud-object-storage
23+
roles:
24+
- crn:v1:bluemix:public:iam::::role:Viewer
25+
- crn:v1:bluemix:public:iam::::role:Operator
26+
- crn:v1:bluemix:public:iam::::role:Editor
27+
- crn:v1:bluemix:public:iam::::role:Administrator
28+
- crn:v1:bluemix:public:iam::::serviceRole:Reader
29+
- crn:v1:bluemix:public:iam::::serviceRole:Writer
30+
- attributes:
31+
- name: resourceType
32+
value: resource-group
33+
roles:
34+
- crn:v1:bluemix:public:iam::::role:Viewer

pkg/storage/ibmcos/ibmcos.go

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,16 @@ func (d *driver) UpdateEffectiveConfig() (*imageregistryv1.ImageRegistryConfigSt
111111
}
112112

113113
var clusterLocation string
114-
if infra.Status.PlatformStatus != nil && infra.Status.PlatformStatus.Type == configapiv1.IBMCloudPlatformType {
115-
clusterLocation = infra.Status.PlatformStatus.IBMCloud.Location
114+
if infra.Status.PlatformStatus != nil {
115+
if infra.Status.PlatformStatus.Type == configapiv1.IBMCloudPlatformType {
116+
clusterLocation = infra.Status.PlatformStatus.IBMCloud.Location
117+
}
118+
if infra.Status.PlatformStatus.Type == configapiv1.PowerVSPlatformType {
119+
clusterLocation, err = cosRegionForPowerVSRegion(infra.Status.PlatformStatus.PowerVS.Region)
120+
if err != nil {
121+
return nil, err
122+
}
123+
}
116124
}
117125

118126
// Use cluster defaults when custom config doesn't define values
@@ -135,8 +143,19 @@ func (d *driver) CreateStorage(cr *imageregistryv1.Config) error {
135143
}
136144

137145
// Set configs from Infrastructure
138-
d.Config.Location = infra.Status.PlatformStatus.IBMCloud.Location
139-
d.Config.ResourceGroupName = infra.Status.PlatformStatus.IBMCloud.ResourceGroupName
146+
if infra.Status.PlatformStatus != nil {
147+
if infra.Status.PlatformStatus.Type == configapiv1.IBMCloudPlatformType {
148+
d.Config.Location = infra.Status.PlatformStatus.IBMCloud.Location
149+
d.Config.ResourceGroupName = infra.Status.PlatformStatus.IBMCloud.ResourceGroupName
150+
}
151+
if infra.Status.PlatformStatus.Type == configapiv1.PowerVSPlatformType {
152+
d.Config.Location, err = cosRegionForPowerVSRegion(infra.Status.PlatformStatus.PowerVS.Region)
153+
if err != nil {
154+
return err
155+
}
156+
d.Config.ResourceGroupName = infra.Status.PlatformStatus.PowerVS.ResourceGroup
157+
}
158+
}
140159

141160
// Initialize IBMCOS status
142161
if cr.Status.Storage.IBMCOS == nil {
@@ -672,8 +691,16 @@ func (d *driver) getIBMCOSClient(serviceInstanceCRN string) (*s3.S3, error) {
672691
}
673692

674693
IBMCOSLocation := imageregistryv1.ImageRegistryConfigStorageIBMCOS{}.Location
675-
if infra.Status.PlatformStatus != nil && infra.Status.PlatformStatus.Type == configapiv1.IBMCloudPlatformType {
676-
IBMCOSLocation = infra.Status.PlatformStatus.IBMCloud.Location
694+
if infra.Status.PlatformStatus != nil {
695+
if infra.Status.PlatformStatus.Type == configapiv1.IBMCloudPlatformType {
696+
IBMCOSLocation = infra.Status.PlatformStatus.IBMCloud.Location
697+
}
698+
if infra.Status.PlatformStatus.Type == configapiv1.PowerVSPlatformType {
699+
IBMCOSLocation, err = cosRegionForPowerVSRegion(infra.Status.PlatformStatus.PowerVS.Region)
700+
if err != nil {
701+
return nil, err
702+
}
703+
}
677704
}
678705

679706
if IBMCOSLocation == "" {

pkg/storage/ibmcos/powervs_regions.go

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package ibmcos
2+
3+
import (
4+
"fmt"
5+
)
6+
7+
// powerVSRegion
8+
// Power VS is a cloud offering of Power Systems in IBM Cloud and COS provides object storage service in IBM Cloud.
9+
// powerVSRegion describes respective IBM Cloud COS region associated with a region in Power VS.
10+
// It helps to decide COS region from Power VS region with the intention to keep COS in same region as Power VS.
11+
// This is required since region notation followed by Power VS is different from COS.
12+
type powerVSRegion struct {
13+
description string
14+
cosRegion string
15+
}
16+
17+
// powerVSRegions provides a mapping between Power VS and COS region.
18+
var powerVSRegions = map[string]powerVSRegion{
19+
"dal": {
20+
description: "Dallas, USA",
21+
cosRegion: "us-south",
22+
},
23+
"eu-de": {
24+
description: "Frankfurt, Germany",
25+
cosRegion: "eu-de",
26+
},
27+
"lon": {
28+
description: "London, UK.",
29+
cosRegion: "eu-gb",
30+
},
31+
"mon": {
32+
description: "Montreal, Canada",
33+
cosRegion: "ca-tor",
34+
},
35+
"osa": {
36+
description: "Osaka, Japan",
37+
cosRegion: "jp-osa",
38+
},
39+
"syd": {
40+
description: "Sydney, Australia",
41+
cosRegion: "au-syd",
42+
},
43+
"sao": {
44+
description: "São Paulo, Brazil",
45+
cosRegion: "br-sao",
46+
},
47+
"tok": {
48+
description: "Tokyo, Japan",
49+
cosRegion: "jp-tok",
50+
},
51+
"us-east": {
52+
description: "Washington DC, USA",
53+
cosRegion: "us-east",
54+
},
55+
}
56+
57+
// cosRegionForPowerVSRegion returns the COS region for the specified Power VS region.
58+
func cosRegionForPowerVSRegion(region string) (string, error) {
59+
if r, ok := powerVSRegions[region]; ok {
60+
return r.cosRegion, nil
61+
}
62+
63+
return "", fmt.Errorf("cos region corresponding to a powervs region %s not found ", region)
64+
}

pkg/storage/storage.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ func GetPlatformStorage(listers *regopclient.StorageListers) (imageregistryv1.Im
185185
configapiv1.NutanixPlatformType,
186186
configapiv1.KubevirtPlatformType,
187187
configapiv1.EquinixMetalPlatformType,
188-
configapiv1.PowerVSPlatformType,
189188
configapiv1.ExternalPlatformType:
190189
break
191190

@@ -201,6 +200,7 @@ func GetPlatformStorage(listers *regopclient.StorageListers) (imageregistryv1.Im
201200
cfg.GCS = &imageregistryv1.ImageRegistryConfigStorageGCS{}
202201
replicas = 2
203202
case configapiv1.IBMCloudPlatformType:
203+
case configapiv1.PowerVSPlatformType:
204204
cfg.IBMCOS = &imageregistryv1.ImageRegistryConfigStorageIBMCOS{}
205205
replicas = 2
206206
case configapiv1.OpenStackPlatformType:

vendor/github.com/openshift/api/config/v1/0000_10_config-operator_01_infrastructure-Default.crd.yaml

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

vendor/github.com/openshift/api/config/v1/0000_10_config-operator_01_infrastructure-TechPreviewNoUpgrade.crd.yaml

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

vendor/github.com/openshift/api/config/v1/stable.infrastructure.testsuite.yaml

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

vendor/github.com/openshift/api/config/v1/types_feature.go

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

0 commit comments

Comments
 (0)