Skip to content

Commit 1e7d483

Browse files
committed
[openstackclient] allow passing in custom environment variables
There is the need to be able to customize the environment variables set in an openstackclient pod, e.g. to specify OpenStack API versions to be used, `OS_COMPUTE_API_VERSION=2.95`. This change adds an env list lot the CRD, like it is in a podSpect which can be used to specify those, but also referencing them from e.g. a secret. In an OpenStackControlPlane CR it would look like: ``` openstackclient: template: env: - name: OS_IDENTITY_API_VERSION value: "3" - name: OS_COMPUTE_API_VERSION value: "2.95" - name: DB_PASSWORD valueFrom: secretKeyRef: key: password name: my-secret ``` Jira: https://issues.redhat.com/browse/OSPRH-13969 Signed-off-by: Martin Schuppert <[email protected]>
1 parent f06dc64 commit 1e7d483

File tree

9 files changed

+438
-0
lines changed

9 files changed

+438
-0
lines changed

apis/bases/client.openstack.org_openstackclients.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,73 @@ spec:
4242
type: string
4343
containerImage:
4444
type: string
45+
env:
46+
items:
47+
properties:
48+
name:
49+
type: string
50+
value:
51+
type: string
52+
valueFrom:
53+
properties:
54+
configMapKeyRef:
55+
properties:
56+
key:
57+
type: string
58+
name:
59+
type: string
60+
optional:
61+
type: boolean
62+
required:
63+
- key
64+
type: object
65+
x-kubernetes-map-type: atomic
66+
fieldRef:
67+
properties:
68+
apiVersion:
69+
type: string
70+
fieldPath:
71+
type: string
72+
required:
73+
- fieldPath
74+
type: object
75+
x-kubernetes-map-type: atomic
76+
resourceFieldRef:
77+
properties:
78+
containerName:
79+
type: string
80+
divisor:
81+
anyOf:
82+
- type: integer
83+
- type: string
84+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
85+
x-kubernetes-int-or-string: true
86+
resource:
87+
type: string
88+
required:
89+
- resource
90+
type: object
91+
x-kubernetes-map-type: atomic
92+
secretKeyRef:
93+
properties:
94+
key:
95+
type: string
96+
name:
97+
type: string
98+
optional:
99+
type: boolean
100+
required:
101+
- key
102+
type: object
103+
x-kubernetes-map-type: atomic
104+
type: object
105+
required:
106+
- name
107+
type: object
108+
type: array
109+
x-kubernetes-list-map-keys:
110+
- name
111+
x-kubernetes-list-type: map
45112
nodeSelector:
46113
additionalProperties:
47114
type: string

apis/bases/core.openstack.org_openstackcontrolplanes.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10003,6 +10003,73 @@ spec:
1000310003
properties:
1000410004
caBundleSecretName:
1000510005
type: string
10006+
env:
10007+
items:
10008+
properties:
10009+
name:
10010+
type: string
10011+
value:
10012+
type: string
10013+
valueFrom:
10014+
properties:
10015+
configMapKeyRef:
10016+
properties:
10017+
key:
10018+
type: string
10019+
name:
10020+
type: string
10021+
optional:
10022+
type: boolean
10023+
required:
10024+
- key
10025+
type: object
10026+
x-kubernetes-map-type: atomic
10027+
fieldRef:
10028+
properties:
10029+
apiVersion:
10030+
type: string
10031+
fieldPath:
10032+
type: string
10033+
required:
10034+
- fieldPath
10035+
type: object
10036+
x-kubernetes-map-type: atomic
10037+
resourceFieldRef:
10038+
properties:
10039+
containerName:
10040+
type: string
10041+
divisor:
10042+
anyOf:
10043+
- type: integer
10044+
- type: string
10045+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
10046+
x-kubernetes-int-or-string: true
10047+
resource:
10048+
type: string
10049+
required:
10050+
- resource
10051+
type: object
10052+
x-kubernetes-map-type: atomic
10053+
secretKeyRef:
10054+
properties:
10055+
key:
10056+
type: string
10057+
name:
10058+
type: string
10059+
optional:
10060+
type: boolean
10061+
required:
10062+
- key
10063+
type: object
10064+
x-kubernetes-map-type: atomic
10065+
type: object
10066+
required:
10067+
- name
10068+
type: object
10069+
type: array
10070+
x-kubernetes-list-map-keys:
10071+
- name
10072+
x-kubernetes-list-type: map
1000610073
nodeSelector:
1000710074
additionalProperties:
1000810075
type: string

apis/client/v1beta1/openstackclient_types.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
1818
"github.com/openstack-k8s-operators/lib-common/modules/common/tls"
1919
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
20+
corev1 "k8s.io/api/core/v1"
2021
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2122
)
2223

@@ -56,6 +57,16 @@ type OpenStackClientSpecCore struct {
5657
// +operator-sdk:csv:customresourcedefinitions:type=spec
5758
// Secret containing any CA certificates which should be added to deployment pods
5859
tls.Ca `json:",inline"`
60+
61+
// +kubebuilder:validation:Optional
62+
// +operator-sdk:csv:customresourcedefinitions:type=spec
63+
// +patchMergeKey=name
64+
// +patchStrategy=merge
65+
// +listType=map
66+
// +listMapKey=name
67+
// +optional
68+
// List of environment variables to set in the container.
69+
Env []corev1.EnvVar `json:"env,omitempty" patchMergeKey:"name" patchStrategy:"merge"`
5970
}
6071

6172
// OpenStackClientStatus defines the observed state of OpenStackClient

apis/client/v1beta1/zz_generated.deepcopy.go

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

bindata/crds/crds.yaml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,73 @@ spec:
4141
type: string
4242
containerImage:
4343
type: string
44+
env:
45+
items:
46+
properties:
47+
name:
48+
type: string
49+
value:
50+
type: string
51+
valueFrom:
52+
properties:
53+
configMapKeyRef:
54+
properties:
55+
key:
56+
type: string
57+
name:
58+
type: string
59+
optional:
60+
type: boolean
61+
required:
62+
- key
63+
type: object
64+
x-kubernetes-map-type: atomic
65+
fieldRef:
66+
properties:
67+
apiVersion:
68+
type: string
69+
fieldPath:
70+
type: string
71+
required:
72+
- fieldPath
73+
type: object
74+
x-kubernetes-map-type: atomic
75+
resourceFieldRef:
76+
properties:
77+
containerName:
78+
type: string
79+
divisor:
80+
anyOf:
81+
- type: integer
82+
- type: string
83+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
84+
x-kubernetes-int-or-string: true
85+
resource:
86+
type: string
87+
required:
88+
- resource
89+
type: object
90+
x-kubernetes-map-type: atomic
91+
secretKeyRef:
92+
properties:
93+
key:
94+
type: string
95+
name:
96+
type: string
97+
optional:
98+
type: boolean
99+
required:
100+
- key
101+
type: object
102+
x-kubernetes-map-type: atomic
103+
type: object
104+
required:
105+
- name
106+
type: object
107+
type: array
108+
x-kubernetes-list-map-keys:
109+
- name
110+
x-kubernetes-list-type: map
44111
nodeSelector:
45112
additionalProperties:
46113
type: string
@@ -10100,6 +10167,73 @@ spec:
1010010167
properties:
1010110168
caBundleSecretName:
1010210169
type: string
10170+
env:
10171+
items:
10172+
properties:
10173+
name:
10174+
type: string
10175+
value:
10176+
type: string
10177+
valueFrom:
10178+
properties:
10179+
configMapKeyRef:
10180+
properties:
10181+
key:
10182+
type: string
10183+
name:
10184+
type: string
10185+
optional:
10186+
type: boolean
10187+
required:
10188+
- key
10189+
type: object
10190+
x-kubernetes-map-type: atomic
10191+
fieldRef:
10192+
properties:
10193+
apiVersion:
10194+
type: string
10195+
fieldPath:
10196+
type: string
10197+
required:
10198+
- fieldPath
10199+
type: object
10200+
x-kubernetes-map-type: atomic
10201+
resourceFieldRef:
10202+
properties:
10203+
containerName:
10204+
type: string
10205+
divisor:
10206+
anyOf:
10207+
- type: integer
10208+
- type: string
10209+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
10210+
x-kubernetes-int-or-string: true
10211+
resource:
10212+
type: string
10213+
required:
10214+
- resource
10215+
type: object
10216+
x-kubernetes-map-type: atomic
10217+
secretKeyRef:
10218+
properties:
10219+
key:
10220+
type: string
10221+
name:
10222+
type: string
10223+
optional:
10224+
type: boolean
10225+
required:
10226+
- key
10227+
type: object
10228+
x-kubernetes-map-type: atomic
10229+
type: object
10230+
required:
10231+
- name
10232+
type: object
10233+
type: array
10234+
x-kubernetes-list-map-keys:
10235+
- name
10236+
x-kubernetes-list-type: map
1010310237
nodeSelector:
1010410238
additionalProperties:
1010510239
type: string

0 commit comments

Comments
 (0)