Skip to content

Commit 2376a18

Browse files
Merge pull request #9194 from shiftstack/OSASINFRA-3657
OSASINFRA-3730: Add support for storing OpenStack CA bundles
2 parents fbf0b65 + 6db3887 commit 2376a18

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

data/data/manifests/openshift/cloud-creds-secret.yaml.template

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ data:
1616
{{- else if .CloudCreds.IBMCloud}}
1717
ibmcloud_api_key: {{.CloudCreds.IBMCloud.Base64encodeAPIKey}}
1818
{{- else if .CloudCreds.OpenStack}}
19-
clouds.yaml: {{.CloudCreds.OpenStack.Base64encodeCloudCreds}}
20-
clouds.conf: {{.CloudCreds.OpenStack.Base64encodeCloudCredsINI}}
19+
clouds.yaml: {{.CloudCreds.OpenStack.Base64encodeCloudsYAML}}
20+
clouds.conf: {{.CloudCreds.OpenStack.Base64encodeCloudsConf}}
21+
{{- if .CloudCreds.OpenStack.Base64encodeCACert}}
22+
cacert: {{.CloudCreds.OpenStack.Base64encodeCACert}}
23+
{{- end}}
2124
{{- else if .CloudCreds.VSphere}}
2225
{{- range .CloudCreds.VSphere}}
2326
{{.VCenter}}.username: {{.Base64encodeUsername}}

pkg/asset/manifests/openshift.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,14 @@ func (o *Openshift) Generate(ctx context.Context, dependencies asset.Parents) er
158158
return err
159159
}
160160

161-
// We need to replace the local cacert path with one that is used in OpenShift
161+
var caCert []byte
162162
if cloud.CACertFile != "" {
163+
var err error
164+
caCert, err = os.ReadFile(cloud.CACertFile)
165+
if err != nil {
166+
return err
167+
}
168+
// We need to replace the local cacert path with one that is used in OpenShift
163169
cloud.CACertFile = "/etc/kubernetes/static-pod-resources/configmaps/cloud-config/ca-bundle.pem"
164170
}
165171

@@ -189,11 +195,13 @@ func (o *Openshift) Generate(ctx context.Context, dependencies asset.Parents) er
189195
}
190196

191197
credsEncoded := base64.StdEncoding.EncodeToString(marshalled)
192-
credsINIEncoded := base64.StdEncoding.EncodeToString(cloudProviderConf)
198+
cloudProviderConfEncoded := base64.StdEncoding.EncodeToString(cloudProviderConf)
199+
caCertEncoded := base64.StdEncoding.EncodeToString(caCert)
193200
cloudCreds = cloudCredsSecretData{
194201
OpenStack: &OpenStackCredsSecretData{
195-
Base64encodeCloudCreds: credsEncoded,
196-
Base64encodeCloudCredsINI: credsINIEncoded,
202+
Base64encodeCloudsYAML: credsEncoded,
203+
Base64encodeCloudsConf: cloudProviderConfEncoded,
204+
Base64encodeCACert: caCertEncoded,
197205
},
198206
}
199207
case vspheretypes.Name:

pkg/asset/manifests/openstack/cloudproviderconfig.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func (e Error) Unwrap() error { return e.err }
2727

2828
// CloudProviderConfigSecret generates the cloud provider config for the OpenStack
2929
// platform, that will be stored in the system secret.
30+
// TODO: I think this is crud for the legacy cloud-provider and is no longer needed. Burn it with fire?
3031
func CloudProviderConfigSecret(cloud *clientconfig.Cloud) ([]byte, error) {
3132
domainID := cloud.AuthInfo.DomainID
3233
if domainID == "" {

pkg/asset/manifests/template.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ type IBMCloudCredsSecretData struct {
3434

3535
// OpenStackCredsSecretData holds encoded credentials and is used to generate cloud-creds secret
3636
type OpenStackCredsSecretData struct {
37-
Base64encodeCloudCreds string
38-
Base64encodeCloudCredsINI string
37+
Base64encodeCloudsYAML string
38+
Base64encodeCloudsConf string
39+
Base64encodeCACert string
3940
}
4041

4142
// VSphereCredsSecretData holds encoded credentials and is used to generated cloud-creds secret

0 commit comments

Comments
 (0)