Skip to content

Commit b67a977

Browse files
committed
Passes ServiceEndpoints from install-config to CAPI
Signed-off-by: Hiro Miyamoto <[email protected]>
1 parent 5b6b221 commit b67a977

File tree

4 files changed

+52
-25
lines changed

4 files changed

+52
-25
lines changed

pkg/asset/cluster/powervs/powervs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ func Metadata(config *types.InstallConfig, meta *icpowervs.Metadata) *powervs.Me
2323
VPCRegion: config.Platform.PowerVS.VPCRegion,
2424
Zone: config.Platform.PowerVS.Zone,
2525
ServiceInstanceGUID: config.Platform.PowerVS.ServiceInstanceGUID,
26+
ServiceEndpoints: config.Platform.PowerVS.ServiceEndpoints,
2627
}
2728
}

pkg/asset/installconfig/powervs/session.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import (
1515
"github.com/IBM/go-sdk-core/v5/core"
1616
"github.com/form3tech-oss/jwt-go"
1717
"github.com/sirupsen/logrus"
18+
"k8s.io/apimachinery/pkg/util/sets"
19+
20+
"github.com/openshift/installer/pkg/types/powervs"
1821
)
1922

2023
var (
@@ -423,3 +426,18 @@ func getEnv(envs []string) string {
423426
}
424427
return ""
425428
}
429+
430+
// FilterServiceEndpoints drops service endpoint overrides that are not supported by PowerVS CAPI provider.
431+
func (c *BxClient) FilterServiceEndpoints(cfg *powervs.Metadata) []string {
432+
capiSupported := sets.New("cos", "powervs", "rc", "rm", "vpc") // see serviceIDs array definition in https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/blob/main/pkg/endpoints/endpoints.go
433+
overrides := make([]string, 0, len(cfg.ServiceEndpoints))
434+
// CAPI expects name=url pairs of service endpoints
435+
for _, endpoint := range cfg.ServiceEndpoints {
436+
if capiSupported.Has(endpoint.Name) {
437+
overrides = append(overrides, fmt.Sprintf("%s=%s", endpoint.Name, endpoint.URL))
438+
} else {
439+
logrus.Infof("Unsupported service endpoint skipped: %s", endpoint.Name)
440+
}
441+
}
442+
return overrides
443+
}

pkg/clusterapi/system.go

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -291,24 +291,29 @@ func (c *system) Run(ctx context.Context) error {
291291
}
292292
APIKey := bxClient.GetBxClientAPIKey()
293293

294-
controllers = append(controllers,
295-
c.getInfrastructureController(
296-
&IBMCloud,
297-
[]string{
298-
"--provider-id-fmt=v2",
299-
"--v=5",
300-
"--health-addr={{suggestHealthHostPort}}",
301-
"--webhook-port={{.WebhookPort}}",
302-
"--webhook-cert-dir={{.WebhookCertDir}}",
303-
},
304-
map[string]string{
305-
"IBMCLOUD_AUTH_TYPE": "iam",
306-
"IBMCLOUD_APIKEY": APIKey,
307-
"IBMCLOUD_AUTH_URL": "https://iam.cloud.ibm.com",
308-
"LOGLEVEL": "5",
309-
},
310-
),
294+
controller := c.getInfrastructureController(
295+
&IBMCloud,
296+
[]string{
297+
"--provider-id-fmt=v2",
298+
"--v=5",
299+
"--health-addr={{suggestHealthHostPort}}",
300+
"--webhook-port={{.WebhookPort}}",
301+
"--webhook-cert-dir={{.WebhookCertDir}}",
302+
},
303+
map[string]string{
304+
"IBMCLOUD_AUTH_TYPE": "iam",
305+
"IBMCLOUD_APIKEY": APIKey,
306+
"IBMCLOUD_AUTH_URL": "https://iam.cloud.ibm.com",
307+
"LOGLEVEL": "5",
308+
},
311309
)
310+
if cfg := metadata.PowerVS; cfg != nil && len(cfg.ServiceEndpoints) > 0 {
311+
overrides := bxClient.FilterServiceEndpoints(cfg)
312+
if len(overrides) > 0 {
313+
controller.Args = append(controller.Args, fmt.Sprintf("--service-endpoint=%s:%s", cfg.Region, strings.Join(overrides, ",")))
314+
}
315+
}
316+
controllers = append(controllers, controller)
312317
default:
313318
return fmt.Errorf("unsupported platform %q", platform)
314319
}

pkg/types/powervs/metadata.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
package powervs
22

3+
import configv1 "github.com/openshift/api/config/v1"
4+
35
// Metadata contains Power VS metadata (e.g. for uninstalling the cluster).
46
type Metadata struct {
5-
BaseDomain string `json:"BaseDomain"`
6-
CISInstanceCRN string `json:"cisInstanceCRN"`
7-
DNSInstanceCRN string `json:"dnsInstanceCRN"`
8-
PowerVSResourceGroup string `json:"powerVSResourceGroup"`
9-
Region string `json:"region"`
10-
VPCRegion string `json:"vpcRegion"`
11-
Zone string `json:"zone"`
12-
ServiceInstanceGUID string `json:"serviceInstanceGUID"`
7+
BaseDomain string `json:"BaseDomain"`
8+
CISInstanceCRN string `json:"cisInstanceCRN"`
9+
DNSInstanceCRN string `json:"dnsInstanceCRN"`
10+
PowerVSResourceGroup string `json:"powerVSResourceGroup"`
11+
Region string `json:"region"`
12+
VPCRegion string `json:"vpcRegion"`
13+
Zone string `json:"zone"`
14+
ServiceInstanceGUID string `json:"serviceInstanceGUID"`
15+
ServiceEndpoints []configv1.PowerVSServiceEndpoint `json:"serviceEndpoints,omitempty"`
1316
}

0 commit comments

Comments
 (0)