Skip to content

Commit 31c35ad

Browse files
committed
Add support for env variables for OFED container
This commit extends NicClusterPolicy to allow to configure environment variables for OFED container. It also streamlines the process of setting env variables during helm deployment. Signed-off-by: amaslennikov <[email protected]>
1 parent 72e9435 commit 31c35ad

File tree

8 files changed

+258
-13
lines changed

8 files changed

+258
-13
lines changed

api/v1alpha1/nicclusterpolicy_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ type OFEDDriverSpec struct {
6565
LivenessProbe *PodProbeSpec `json:"livenessProbe,omitempty"`
6666
// Pod readiness probe settings
6767
ReadinessProbe *PodProbeSpec `json:"readinessProbe,omitempty"`
68+
// List of environment variables to set in the OFED container.
69+
Env []v1.EnvVar `json:"env,omitempty"`
6870
// Ofed auto-upgrade settings
6971
OfedUpgradePolicy *OfedUpgradePolicySpec `json:"upgradePolicy,omitempty"`
7072
}

api/v1alpha1/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.

config/crd/bases/mellanox.com_nicclusterpolicies.yaml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,116 @@ spec:
266266
description: OFEDDriverSpec describes configuration options for OFED
267267
driver
268268
properties:
269+
env:
270+
description: List of environment variables to set in the OFED
271+
container.
272+
items:
273+
description: EnvVar represents an environment variable present
274+
in a Container.
275+
properties:
276+
name:
277+
description: Name of the environment variable. Must be a
278+
C_IDENTIFIER.
279+
type: string
280+
value:
281+
description: 'Variable references $(VAR_NAME) are expanded
282+
using the previous defined environment variables in the
283+
container and any service environment variables. If a
284+
variable cannot be resolved, the reference in the input
285+
string will be unchanged. The $(VAR_NAME) syntax can be
286+
escaped with a double $$, ie: $$(VAR_NAME). Escaped references
287+
will never be expanded, regardless of whether the variable
288+
exists or not. Defaults to "".'
289+
type: string
290+
valueFrom:
291+
description: Source for the environment variable's value.
292+
Cannot be used if value is not empty.
293+
properties:
294+
configMapKeyRef:
295+
description: Selects a key of a ConfigMap.
296+
properties:
297+
key:
298+
description: The key to select.
299+
type: string
300+
name:
301+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
302+
TODO: Add other useful fields. apiVersion, kind,
303+
uid?'
304+
type: string
305+
optional:
306+
description: Specify whether the ConfigMap or its
307+
key must be defined
308+
type: boolean
309+
required:
310+
- key
311+
type: object
312+
fieldRef:
313+
description: 'Selects a field of the pod: supports metadata.name,
314+
metadata.namespace, `metadata.labels[''<KEY>'']`,
315+
`metadata.annotations[''<KEY>'']`, spec.nodeName,
316+
spec.serviceAccountName, status.hostIP, status.podIP,
317+
status.podIPs.'
318+
properties:
319+
apiVersion:
320+
description: Version of the schema the FieldPath
321+
is written in terms of, defaults to "v1".
322+
type: string
323+
fieldPath:
324+
description: Path of the field to select in the
325+
specified API version.
326+
type: string
327+
required:
328+
- fieldPath
329+
type: object
330+
resourceFieldRef:
331+
description: 'Selects a resource of the container: only
332+
resources limits and requests (limits.cpu, limits.memory,
333+
limits.ephemeral-storage, requests.cpu, requests.memory
334+
and requests.ephemeral-storage) are currently supported.'
335+
properties:
336+
containerName:
337+
description: 'Container name: required for volumes,
338+
optional for env vars'
339+
type: string
340+
divisor:
341+
anyOf:
342+
- type: integer
343+
- type: string
344+
description: Specifies the output format of the
345+
exposed resources, defaults to "1"
346+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
347+
x-kubernetes-int-or-string: true
348+
resource:
349+
description: 'Required: resource to select'
350+
type: string
351+
required:
352+
- resource
353+
type: object
354+
secretKeyRef:
355+
description: Selects a key of a secret in the pod's
356+
namespace
357+
properties:
358+
key:
359+
description: The key of the secret to select from. Must
360+
be a valid secret key.
361+
type: string
362+
name:
363+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
364+
TODO: Add other useful fields. apiVersion, kind,
365+
uid?'
366+
type: string
367+
optional:
368+
description: Specify whether the Secret or its key
369+
must be defined
370+
type: boolean
371+
required:
372+
- key
373+
type: object
374+
type: object
375+
required:
376+
- name
377+
type: object
378+
type: array
269379
image:
270380
pattern: '[a-zA-Z0-9\-]+'
271381
type: string

deployment/network-operator/README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -341,19 +341,20 @@ Production cluster environment can deny direct access to the Internet and instea
341341

342342
#### Mellanox OFED driver
343343

344-
| Name | Type | Default | description |
345-
| ---- | ---- | ------- | ----------- |
346-
| `ofedDriver.deploy` | bool | `false` | deploy Mellanox OFED driver container |
347-
| `ofedDriver.repository` | string | `mellanox` | Mellanox OFED driver image repository |
348-
| `ofedDriver.image` | string | `mofed` | Mellanox OFED driver image name |
349-
| `ofedDriver.version` | string | `5.5-1.0.3.2` | Mellanox OFED driver version |
350-
| `ofedDriver.imagePullSecrets` | list | `[]` | An optional list of references to secrets to use for pulling any of the Mellanox OFED driver image |
351-
| `ofedDriver.startupProbe.initialDelaySeconds` | int | 10 | Mellanox OFED startup probe initial delay |
352-
| `ofedDriver.startupProbe.periodSeconds` | int | 20 | Mellanox OFED startup probe interval |
353-
| `ofedDriver.livenessProbe.initialDelaySeconds` | int | 30 | Mellanox OFED liveness probe initial delay |
354-
| `ofedDriver.livenessProbe.periodSeconds` | int | 30 | Mellanox OFED liveness probe interval|
355-
| `ofedDriver.readinessProbe.initialDelaySeconds` | int | 10 | Mellanox OFED readiness probe initial delay |
356-
| `ofedDriver.readinessProbe.periodSeconds` | int | 30 | Mellanox OFED readiness probe interval |
344+
| Name | Type | Default | description |
345+
| ---- | ---- | ------- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
346+
| `ofedDriver.deploy` | bool | `false` | deploy Mellanox OFED driver container |
347+
| `ofedDriver.repository` | string | `mellanox` | Mellanox OFED driver image repository |
348+
| `ofedDriver.image` | string | `mofed` | Mellanox OFED driver image name |
349+
| `ofedDriver.version` | string | `5.5-1.0.3.2` | Mellanox OFED driver version |
350+
| `ofedDriver.imagePullSecrets` | list | `[]` | An optional list of references to secrets to use for pulling any of the Mellanox OFED driver image |
351+
| `ofedDriver.env` | list | `[]` | An optional list of [environment variables](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#envvar-v1-core) passed to the Mellanox OFED driver image |
352+
| `ofedDriver.startupProbe.initialDelaySeconds` | int | 10 | Mellanox OFED startup probe initial delay |
353+
| `ofedDriver.startupProbe.periodSeconds` | int | 20 | Mellanox OFED startup probe interval |
354+
| `ofedDriver.livenessProbe.initialDelaySeconds` | int | 30 | Mellanox OFED liveness probe initial delay |
355+
| `ofedDriver.livenessProbe.periodSeconds` | int | 30 | Mellanox OFED liveness probe interval |
356+
| `ofedDriver.readinessProbe.initialDelaySeconds` | int | 10 | Mellanox OFED readiness probe initial delay |
357+
| `ofedDriver.readinessProbe.periodSeconds` | int | 30 | Mellanox OFED readiness probe interval |
357358

358359
#### NVIDIA Peer memory driver
359360

deployment/network-operator/crds/mellanox.com_nicclusterpolicies.yaml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,116 @@ spec:
266266
description: OFEDDriverSpec describes configuration options for OFED
267267
driver
268268
properties:
269+
env:
270+
description: List of environment variables to set in the OFED
271+
container.
272+
items:
273+
description: EnvVar represents an environment variable present
274+
in a Container.
275+
properties:
276+
name:
277+
description: Name of the environment variable. Must be a
278+
C_IDENTIFIER.
279+
type: string
280+
value:
281+
description: 'Variable references $(VAR_NAME) are expanded
282+
using the previous defined environment variables in the
283+
container and any service environment variables. If a
284+
variable cannot be resolved, the reference in the input
285+
string will be unchanged. The $(VAR_NAME) syntax can be
286+
escaped with a double $$, ie: $$(VAR_NAME). Escaped references
287+
will never be expanded, regardless of whether the variable
288+
exists or not. Defaults to "".'
289+
type: string
290+
valueFrom:
291+
description: Source for the environment variable's value.
292+
Cannot be used if value is not empty.
293+
properties:
294+
configMapKeyRef:
295+
description: Selects a key of a ConfigMap.
296+
properties:
297+
key:
298+
description: The key to select.
299+
type: string
300+
name:
301+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
302+
TODO: Add other useful fields. apiVersion, kind,
303+
uid?'
304+
type: string
305+
optional:
306+
description: Specify whether the ConfigMap or its
307+
key must be defined
308+
type: boolean
309+
required:
310+
- key
311+
type: object
312+
fieldRef:
313+
description: 'Selects a field of the pod: supports metadata.name,
314+
metadata.namespace, `metadata.labels[''<KEY>'']`,
315+
`metadata.annotations[''<KEY>'']`, spec.nodeName,
316+
spec.serviceAccountName, status.hostIP, status.podIP,
317+
status.podIPs.'
318+
properties:
319+
apiVersion:
320+
description: Version of the schema the FieldPath
321+
is written in terms of, defaults to "v1".
322+
type: string
323+
fieldPath:
324+
description: Path of the field to select in the
325+
specified API version.
326+
type: string
327+
required:
328+
- fieldPath
329+
type: object
330+
resourceFieldRef:
331+
description: 'Selects a resource of the container: only
332+
resources limits and requests (limits.cpu, limits.memory,
333+
limits.ephemeral-storage, requests.cpu, requests.memory
334+
and requests.ephemeral-storage) are currently supported.'
335+
properties:
336+
containerName:
337+
description: 'Container name: required for volumes,
338+
optional for env vars'
339+
type: string
340+
divisor:
341+
anyOf:
342+
- type: integer
343+
- type: string
344+
description: Specifies the output format of the
345+
exposed resources, defaults to "1"
346+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
347+
x-kubernetes-int-or-string: true
348+
resource:
349+
description: 'Required: resource to select'
350+
type: string
351+
required:
352+
- resource
353+
type: object
354+
secretKeyRef:
355+
description: Selects a key of a secret in the pod's
356+
namespace
357+
properties:
358+
key:
359+
description: The key of the secret to select from. Must
360+
be a valid secret key.
361+
type: string
362+
name:
363+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
364+
TODO: Add other useful fields. apiVersion, kind,
365+
uid?'
366+
type: string
367+
optional:
368+
description: Specify whether the Secret or its key
369+
must be defined
370+
type: boolean
371+
required:
372+
- key
373+
type: object
374+
type: object
375+
required:
376+
- name
377+
type: object
378+
type: array
269379
image:
270380
pattern: '[a-zA-Z0-9\-]+'
271381
type: string

deployment/network-operator/templates/mellanox.com_v1alpha1_nicclusterpolicy_cr.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ spec:
2424
image: {{ .Values.ofedDriver.image }}
2525
repository: {{ .Values.ofedDriver.repository }}
2626
version: {{ .Values.ofedDriver.version }}
27+
{{- if .Values.ofedDriver.env }}
28+
env:
29+
{{ toYaml .Values.ofedDriver.env | nindent 6 }}
30+
{{- end }}
2731
imagePullSecrets: {{ include "network-operator.ofed.imagePullSecrets" . | nindent 4 }}
2832
startupProbe:
2933
initialDelaySeconds: {{ .Values.ofedDriver.startupProbe.initialDelaySeconds }}

deployment/network-operator/values.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ ofedDriver:
149149
repository: nvcr.io/nvidia/mellanox
150150
version: 5.6-1.0.3.3
151151
imagePullSecrets: []
152+
# env, if defined will pass environment variables to the OFED container
153+
# env:
154+
# - name: EXAMPLE_ENV_VAR
155+
# value: example_env_var_value
156+
152157
startupProbe:
153158
initialDelaySeconds: 10
154159
periodSeconds: 20

manifests/stage-ofed-driver/0050_ofed-driver-ds.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ spec:
6868
value: {{ .RuntimeSpec.HTTPSProxy }}
6969
- name: NO_PROXY
7070
value: {{ .RuntimeSpec.NoProxy }}
71+
{{- if .CrSpec.Env }}
72+
{{- range .CrSpec.Env }}
73+
{{ . | yaml | nindentPrefix 14 "- " }}
74+
{{- end }}
75+
{{- end }}
7176
volumeMounts:
7277
- name: run-mlnx-ofed
7378
mountPath: /run/mellanox/drivers

0 commit comments

Comments
 (0)