Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit 1d01a75

Browse files
⚠️ Add default values for the 'cloudName' and 'identityRef' fields (#101)
* Add default values for the 'cloudName' and 'identityRef' fields Signed-off-by: michal.gubricky <[email protected]> * Catch unknown error from the getCloudNameFromSecret function Signed-off-by: michal.gubricky <[email protected]> * Change the severity of unknown error to warning Signed-off-by: michal.gubricky <[email protected]> * Fix yaml lint warnings Signed-off-by: michal.gubricky <[email protected]> * Update config/cspo/secret.yaml Co-authored-by: Matej Feder <[email protected]> Signed-off-by: Michal Gubricky <[email protected]> * Replace <my-cloud-secret> with openstack in docs Signed-off-by: michal.gubricky <[email protected]> * Get rid off the spec.CloudName field from the OpenStackNodeImageRelease resource Signed-off-by: michal.gubricky <[email protected]> * Move defaultCloudName into const Signed-off-by: michal.gubricky <[email protected]> --------- Signed-off-by: michal.gubricky <[email protected]> Signed-off-by: Michal Gubricky <[email protected]> Co-authored-by: Matej Feder <[email protected]>
1 parent 731ffe1 commit 1d01a75

16 files changed

+86
-61
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,15 @@ clusterctl init --infrastructure openstack
4646
To enable communication between the CSPO and the Cluster API Provider for OpenStack (CAPO) with the OpenStack API, it is necessary to generate a secret containing the access data (clouds.yaml).
4747
Ensure that this secret is located in the identical namespace as the other Custom Resources.
4848

49+
> [!NOTE]
50+
> The default value of `cloudName` is configured as `openstack`. This setting can be overridden by including the `cloudName` key in the secret. Also, be aware that the name of the secret is expected to be `openstack` unless it is not set differently in OpenStackClusterStackReleaseTemplate in `identityRef.name` field.
51+
4952
```bash
50-
kubectl create secret generic <my-cloud-secret> --from-file=clouds.yaml=path/to/clouds.yaml
53+
kubectl create secret generic openstack --from-file=clouds.yaml=path/to/clouds.yaml
5154

5255
# Patch the created secrets so they are automatically moved to the target cluster later.
5356

54-
kubectl patch secret <my-cloud-secret> -p '{"metadata":{"labels":{"clusterctl.cluster.x-k8s.io/move":""}}}'
57+
kubectl patch secret openstack -p '{"metadata":{"labels":{"clusterctl.cluster.x-k8s.io/move":""}}}'
5558
```
5659

5760
### CSO and CSPO variables preparation

Tiltfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def deploy_cspo():
268268

269269
def create_secret():
270270
cmd = "cat .secret.yaml | {} | kubectl apply -f -".format(envsubst_cmd)
271-
local_resource('supersecret', cmd, labels=["clouds-yaml-secret"])
271+
local_resource('supersecret', cmd, labels=["clouds-yaml-secret"])
272272

273273
def cspo_template():
274274
cmd = "cat .cspotemplate.yaml | {}".format(envsubst_cmd)

api/v1alpha1/openstackclusterstackrelease_types.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ import (
2727

2828
// OpenStackClusterStackReleaseSpec defines the desired state of OpenStackClusterStackRelease.
2929
type OpenStackClusterStackReleaseSpec struct {
30-
// CloudName is the name of the cloud to use from the cloud's secret.
31-
// +kubebuilder:validation:MinLength=1
32-
CloudName string `json:"cloudName"`
3330
// IdentityRef is a reference to a identity to be used when reconciling this cluster
31+
// +optional
32+
// +kubebuilder:default:={kind: "Secret", name: "openstack"}
3433
IdentityRef *apiv1alpha7.OpenStackIdentityReference `json:"identityRef"`
3534
}
3635

api/v1alpha1/openstacknodeimagerelease_types.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ import (
2828

2929
// OpenStackNodeImageReleaseSpec defines the desired state of OpenStackNodeImageRelease.
3030
type OpenStackNodeImageReleaseSpec struct {
31-
// CloudName is the name of the cloud to use from the cloud's secret.
32-
// +kubebuilder:validation:MinLength=1
33-
CloudName string `json:"cloudName"`
3431
// IdentityRef is a reference to a identity to be used when reconciling this cluster
3532
IdentityRef *apiv1alpha7.OpenStackIdentityReference `json:"identityRef"`
3633
// Image represents options used to upload an image

config/crd/bases/infrastructure.clusterstack.x-k8s.io_openstackclusterstackreleases.yaml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,10 @@ spec:
5252
description: OpenStackClusterStackReleaseSpec defines the desired state
5353
of OpenStackClusterStackRelease.
5454
properties:
55-
cloudName:
56-
description: CloudName is the name of the cloud to use from the cloud's
57-
secret.
58-
minLength: 1
59-
type: string
6055
identityRef:
56+
default:
57+
kind: Secret
58+
name: openstack
6159
description: IdentityRef is a reference to a identity to be used when
6260
reconciling this cluster
6361
properties:
@@ -75,9 +73,6 @@ spec:
7573
- kind
7674
- name
7775
type: object
78-
required:
79-
- cloudName
80-
- identityRef
8176
type: object
8277
status:
8378
description: OpenStackClusterStackReleaseStatus defines the observed state

config/crd/bases/infrastructure.clusterstack.x-k8s.io_openstackclusterstackreleasetemplates.yaml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,10 @@ spec:
4747
description: OpenStackClusterStackReleaseSpec defines the desired
4848
state of OpenStackClusterStackRelease.
4949
properties:
50-
cloudName:
51-
description: CloudName is the name of the cloud to use from
52-
the cloud's secret.
53-
minLength: 1
54-
type: string
5550
identityRef:
51+
default:
52+
kind: Secret
53+
name: openstack
5654
description: IdentityRef is a reference to a identity to be
5755
used when reconciling this cluster
5856
properties:
@@ -72,9 +70,6 @@ spec:
7270
- kind
7371
- name
7472
type: object
75-
required:
76-
- cloudName
77-
- identityRef
7873
type: object
7974
required:
8075
- spec

config/crd/bases/infrastructure.clusterstack.x-k8s.io_openstacknodeimagereleases.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ spec:
5252
description: OpenStackNodeImageReleaseSpec defines the desired state of
5353
OpenStackNodeImageRelease.
5454
properties:
55-
cloudName:
56-
description: CloudName is the name of the cloud to use from the cloud's
57-
secret.
58-
minLength: 1
59-
type: string
6055
identityRef:
6156
description: IdentityRef is a reference to a identity to be used when
6257
reconciling this cluster
@@ -129,7 +124,6 @@ spec:
129124
- url
130125
type: object
131126
required:
132-
- cloudName
133127
- identityRef
134128
- image
135129
type: object

config/cspo/cspotemplate.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ metadata:
55
namespace: cluster
66
spec:
77
template:
8-
spec:
9-
cloudName: "${CLOUD_NAME}"
10-
identityRef:
11-
kind: Secret
12-
name: "${SECRET_NAME}"
8+
spec: {}
9+
# Field identityRef is optional and its default values are as follows:
10+
# identityRef.kind: "Secret", identityRef.name: "openstack"
11+
# identityRef:
12+
# kind: Secret
13+
# name: "<your-secret-name>"

config/cspo/secret.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
apiVersion: v1
22
data:
3+
# The default value of `cloudName` is configured as `openstack`.
4+
# This can be overridden by including the `cloudName` key in this secret.
5+
# cloudName: "openstack"
36
clouds.yaml: ${ENCODED_CLOUDS_YAML}
47
kind: Secret
58
metadata:
69
labels:
710
clusterctl.cluster.x-k8s.io/move: "true"
8-
name: "${SECRET_NAME}"
11+
# Note: `metadata.name` must be the same as the value of the field
12+
# `identityRef.name` in OpenStackClusterStackReleaseTemplate object.
13+
name: "openstack"
914
namespace: cluster

examples/cspotemplate.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ metadata:
55
spec:
66
template:
77
spec:
8-
cloudName: <name of the cloud to use from the clouds secret>
8+
# Field identityRef is optional and its default values ​​are as follows:
9+
# identityRef.kind: "Secret", identityRef.name: "openstack"
910
identityRef:
1011
kind: Secret
1112
name: <my-secret>

0 commit comments

Comments
 (0)