Skip to content

Commit 0c730d3

Browse files
Merge pull request #155 from srl-labs/feat/extra-envs-for-launchers
feat: add extraEnv support at topology and global config
2 parents 44fe1b5 + 3d00dc0 commit 0c730d3

18 files changed

+629
-2
lines changed

apis/v1alpha1/configspec.go

+5
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ type ConfigDeployment struct {
7979
// +kubebuilder:validation:Enum=disabled;critical;warn;info;debug
8080
// +optional
8181
LauncherLogLevel string `json:"launcherLogLevel,omitempty"`
82+
// ExtraEnv is a list of additional environment variables to set on the launcher container. The
83+
// values here are applied to *all* launchers since this is the global config after all!
84+
// +optional
85+
// +listType=atomic
86+
ExtraEnv []k8scorev1.EnvVar `json:"extraEnv"`
8287
}
8388

8489
// ConfigImagePull holds configurations relevant to how clabernetes launcher pods handle pulling

apis/v1alpha1/topologyspec.go

+5
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ type Deployment struct {
179179
// +kubebuilder:validation:Enum=disabled;critical;warn;info;debug
180180
// +optional
181181
LauncherLogLevel string `json:"launcherLogLevel,omitempty"`
182+
// ExtraEnv is a list of additional environment variables to set on the launcher container. The
183+
// values here override any configured global config extra envs!
184+
// +optional
185+
// +listType=atomic
186+
ExtraEnv []k8scorev1.EnvVar `json:"extraEnv"`
182187
}
183188

184189
// Scheduling holds information about how the launcher pod(s) should be configured with respect

apis/v1alpha1/zz_generated.deepcopy.go

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/crd/clabernetes.containerlab.dev_configs.yaml

+127
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,133 @@ spec:
6868
some new feature (but do note that just because it exists in containerlab doesnt
6969
*necessarily* mean it will be auto-working in clabernetes!
7070
type: string
71+
extraEnv:
72+
description: |-
73+
ExtraEnv is a list of additional environment variables to set on the launcher container. The
74+
values here are applied to *all* launchers since this is the global config after all!
75+
items:
76+
description: EnvVar represents an environment variable present
77+
in a Container.
78+
properties:
79+
name:
80+
description: Name of the environment variable. Must be a
81+
C_IDENTIFIER.
82+
type: string
83+
value:
84+
description: |-
85+
Variable references $(VAR_NAME) are expanded
86+
using the previously defined environment variables in the container and
87+
any service environment variables. If a variable cannot be resolved,
88+
the reference in the input string will be unchanged. Double $$ are reduced
89+
to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e.
90+
"$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)".
91+
Escaped references will never be expanded, regardless of whether the variable
92+
exists or not.
93+
Defaults to "".
94+
type: string
95+
valueFrom:
96+
description: Source for the environment variable's value.
97+
Cannot be used if value is not empty.
98+
properties:
99+
configMapKeyRef:
100+
description: Selects a key of a ConfigMap.
101+
properties:
102+
key:
103+
description: The key to select.
104+
type: string
105+
name:
106+
default: ""
107+
description: |-
108+
Name of the referent.
109+
This field is effectively required, but due to backwards compatibility is
110+
allowed to be empty. Instances of this type with an empty value here are
111+
almost certainly wrong.
112+
TODO: Add other useful fields. apiVersion, kind, uid?
113+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
114+
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
115+
type: string
116+
optional:
117+
description: Specify whether the ConfigMap or its
118+
key must be defined
119+
type: boolean
120+
required:
121+
- key
122+
type: object
123+
x-kubernetes-map-type: atomic
124+
fieldRef:
125+
description: |-
126+
Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['<KEY>']`, `metadata.annotations['<KEY>']`,
127+
spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs.
128+
properties:
129+
apiVersion:
130+
description: Version of the schema the FieldPath
131+
is written in terms of, defaults to "v1".
132+
type: string
133+
fieldPath:
134+
description: Path of the field to select in the
135+
specified API version.
136+
type: string
137+
required:
138+
- fieldPath
139+
type: object
140+
x-kubernetes-map-type: atomic
141+
resourceFieldRef:
142+
description: |-
143+
Selects a resource of the container: only resources limits and requests
144+
(limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported.
145+
properties:
146+
containerName:
147+
description: 'Container name: required for volumes,
148+
optional for env vars'
149+
type: string
150+
divisor:
151+
anyOf:
152+
- type: integer
153+
- type: string
154+
description: Specifies the output format of the
155+
exposed resources, defaults to "1"
156+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
157+
x-kubernetes-int-or-string: true
158+
resource:
159+
description: 'Required: resource to select'
160+
type: string
161+
required:
162+
- resource
163+
type: object
164+
x-kubernetes-map-type: atomic
165+
secretKeyRef:
166+
description: Selects a key of a secret in the pod's
167+
namespace
168+
properties:
169+
key:
170+
description: The key of the secret to select from. Must
171+
be a valid secret key.
172+
type: string
173+
name:
174+
default: ""
175+
description: |-
176+
Name of the referent.
177+
This field is effectively required, but due to backwards compatibility is
178+
allowed to be empty. Instances of this type with an empty value here are
179+
almost certainly wrong.
180+
TODO: Add other useful fields. apiVersion, kind, uid?
181+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
182+
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
183+
type: string
184+
optional:
185+
description: Specify whether the Secret or its key
186+
must be defined
187+
type: boolean
188+
required:
189+
- key
190+
type: object
191+
x-kubernetes-map-type: atomic
192+
type: object
193+
required:
194+
- name
195+
type: object
196+
type: array
197+
x-kubernetes-list-type: atomic
71198
launcherImage:
72199
default: ghcr.io/srl-labs/clabernetes/clabernetes-launcher:latest
73200
description: LauncherImage sets the default launcher image to

assets/crd/clabernetes.containerlab.dev_topologies.yaml

+127
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,133 @@ spec:
103103
some new feature (but do note that just because it exists in containerlab doesnt
104104
*necessarily* mean it will be auto-working in clabernetes!
105105
type: string
106+
extraEnv:
107+
description: |-
108+
ExtraEnv is a list of additional environment variables to set on the launcher container. The
109+
values here override any configured global config extra envs!
110+
items:
111+
description: EnvVar represents an environment variable present
112+
in a Container.
113+
properties:
114+
name:
115+
description: Name of the environment variable. Must be a
116+
C_IDENTIFIER.
117+
type: string
118+
value:
119+
description: |-
120+
Variable references $(VAR_NAME) are expanded
121+
using the previously defined environment variables in the container and
122+
any service environment variables. If a variable cannot be resolved,
123+
the reference in the input string will be unchanged. Double $$ are reduced
124+
to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e.
125+
"$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)".
126+
Escaped references will never be expanded, regardless of whether the variable
127+
exists or not.
128+
Defaults to "".
129+
type: string
130+
valueFrom:
131+
description: Source for the environment variable's value.
132+
Cannot be used if value is not empty.
133+
properties:
134+
configMapKeyRef:
135+
description: Selects a key of a ConfigMap.
136+
properties:
137+
key:
138+
description: The key to select.
139+
type: string
140+
name:
141+
default: ""
142+
description: |-
143+
Name of the referent.
144+
This field is effectively required, but due to backwards compatibility is
145+
allowed to be empty. Instances of this type with an empty value here are
146+
almost certainly wrong.
147+
TODO: Add other useful fields. apiVersion, kind, uid?
148+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
149+
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
150+
type: string
151+
optional:
152+
description: Specify whether the ConfigMap or its
153+
key must be defined
154+
type: boolean
155+
required:
156+
- key
157+
type: object
158+
x-kubernetes-map-type: atomic
159+
fieldRef:
160+
description: |-
161+
Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['<KEY>']`, `metadata.annotations['<KEY>']`,
162+
spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs.
163+
properties:
164+
apiVersion:
165+
description: Version of the schema the FieldPath
166+
is written in terms of, defaults to "v1".
167+
type: string
168+
fieldPath:
169+
description: Path of the field to select in the
170+
specified API version.
171+
type: string
172+
required:
173+
- fieldPath
174+
type: object
175+
x-kubernetes-map-type: atomic
176+
resourceFieldRef:
177+
description: |-
178+
Selects a resource of the container: only resources limits and requests
179+
(limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported.
180+
properties:
181+
containerName:
182+
description: 'Container name: required for volumes,
183+
optional for env vars'
184+
type: string
185+
divisor:
186+
anyOf:
187+
- type: integer
188+
- type: string
189+
description: Specifies the output format of the
190+
exposed resources, defaults to "1"
191+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
192+
x-kubernetes-int-or-string: true
193+
resource:
194+
description: 'Required: resource to select'
195+
type: string
196+
required:
197+
- resource
198+
type: object
199+
x-kubernetes-map-type: atomic
200+
secretKeyRef:
201+
description: Selects a key of a secret in the pod's
202+
namespace
203+
properties:
204+
key:
205+
description: The key of the secret to select from. Must
206+
be a valid secret key.
207+
type: string
208+
name:
209+
default: ""
210+
description: |-
211+
Name of the referent.
212+
This field is effectively required, but due to backwards compatibility is
213+
allowed to be empty. Instances of this type with an empty value here are
214+
almost certainly wrong.
215+
TODO: Add other useful fields. apiVersion, kind, uid?
216+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
217+
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
218+
type: string
219+
optional:
220+
description: Specify whether the Secret or its key
221+
must be defined
222+
type: boolean
223+
required:
224+
- key
225+
type: object
226+
x-kubernetes-map-type: atomic
227+
type: object
228+
required:
229+
- name
230+
type: object
231+
type: array
232+
x-kubernetes-list-type: atomic
106233
filesFromConfigMap:
107234
additionalProperties:
108235
items:

0 commit comments

Comments
 (0)