Skip to content

Commit 2ff4d63

Browse files
yevgeny-shnaidmanybettan
authored andcommitted
Allow configuring AutomountServiceAccountToken for DevicePlugin
AutomountServiceAccountToken is used to disable the auto-mounting of the projected volume into device plugin pod. This volume includes as files: SA token, CAs' file etc'. K8s automatically mounts the SA token, root CAs into the /var/run/secrets/kubernetes.io/serviceaccount using projected volumes.As a result, mounting/overriding additional files into that directory is not allowed. setting AutomountServiceAccountToken to false, will disale auto-mounting, and will allow user to mount whatever configmaps and tokens he deems necessary for the device plugin application.
1 parent 1ec2ff1 commit 2ff4d63

11 files changed

Lines changed: 62 additions & 13 deletions

api/v1beta1/module_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,12 @@ type DevicePluginSpec struct {
313313
ServiceAccountName string `json:"serviceAccountName,omitempty"`
314314

315315
Volumes []v1.Volume `json:"volumes,omitempty"`
316+
317+
// AutomountServiceAccountToken is used to disable the auto-mounting of the projected volume
318+
// into device plugin pod. This volume includes as files: SA token, CAs' file etc'
319+
// setting AutomountServiceAccountToken to false, will disale auto-mounting, and will allow user to mount
320+
// whatever configmaps and tokens he deems necessary for the device plugin application
321+
AutomountServiceAccountToken *bool `json:"automountServiceAccountToken,omitempty"`
316322
}
317323

318324
// ModuleSpec describes how the KMM operator should deploy a Module on those nodes that need it.

api/v1beta1/zz_generated.deepcopy.go

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

bundle-hub/manifests/hub.kmm.sigs.x-k8s.io_managedclustermodules.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ spec:
5353
DevicePlugin allows overriding some properties of the container that deploys the device plugin on the node.
5454
Name is ignored and is set automatically by the KMM Operator.
5555
properties:
56+
automountServiceAccountToken:
57+
description: |-
58+
AutomountServiceAccountToken is used to disable the auto-mounting of the projected volume
59+
into device plugin pod. This volume includes as files: SA token, CAs' file etc'
60+
setting AutomountServiceAccountToken to false, will disale auto-mounting, and will allow user to mount
61+
whatever configmaps and tokens he deems necessary for the device plugin application
62+
type: boolean
5663
container:
5764
properties:
5865
args:

bundle-hub/manifests/kernel-module-management-hub.clusterserviceversion.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ metadata:
3737
}
3838
]
3939
capabilities: Seamless Upgrades
40-
createdAt: "2026-02-10T11:50:11Z"
40+
createdAt: "2026-02-15T12:41:06Z"
4141
operatorframework.io/suggested-namespace: openshift-kmm-hub
4242
operators.operatorframework.io/builder: operator-sdk-v1.41.1
4343
operators.operatorframework.io/project_layout: go.kubebuilder.io/v4

bundle/manifests/kernel-module-management.clusterserviceversion.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ metadata:
4747
}
4848
]
4949
capabilities: Seamless Upgrades
50-
createdAt: "2026-02-10T11:50:10Z"
50+
createdAt: "2026-02-15T12:40:55Z"
5151
operatorframework.io/suggested-namespace: openshift-kmm
5252
operators.operatorframework.io/builder: operator-sdk-v1.41.1
5353
operators.operatorframework.io/project_layout: go.kubebuilder.io/v4

bundle/manifests/kmm.sigs.x-k8s.io_modules.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ spec:
4949
DevicePlugin allows overriding some properties of the container that deploys the device plugin on the node.
5050
Name is ignored and is set automatically by the KMM Operator.
5151
properties:
52+
automountServiceAccountToken:
53+
description: |-
54+
AutomountServiceAccountToken is used to disable the auto-mounting of the projected volume
55+
into device plugin pod. This volume includes as files: SA token, CAs' file etc'
56+
setting AutomountServiceAccountToken to false, will disale auto-mounting, and will allow user to mount
57+
whatever configmaps and tokens he deems necessary for the device plugin application
58+
type: boolean
5259
container:
5360
properties:
5461
args:

config/crd-hub/bases/hub.kmm.sigs.x-k8s.io_managedclustermodules.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ spec:
4949
DevicePlugin allows overriding some properties of the container that deploys the device plugin on the node.
5050
Name is ignored and is set automatically by the KMM Operator.
5151
properties:
52+
automountServiceAccountToken:
53+
description: |-
54+
AutomountServiceAccountToken is used to disable the auto-mounting of the projected volume
55+
into device plugin pod. This volume includes as files: SA token, CAs' file etc'
56+
setting AutomountServiceAccountToken to false, will disale auto-mounting, and will allow user to mount
57+
whatever configmaps and tokens he deems necessary for the device plugin application
58+
type: boolean
5259
container:
5360
properties:
5461
args:

config/crd-hub/bases/kmm.sigs.x-k8s.io_modules.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ spec:
4545
DevicePlugin allows overriding some properties of the container that deploys the device plugin on the node.
4646
Name is ignored and is set automatically by the KMM Operator.
4747
properties:
48+
automountServiceAccountToken:
49+
description: |-
50+
AutomountServiceAccountToken is used to disable the auto-mounting of the projected volume
51+
into device plugin pod. This volume includes as files: SA token, CAs' file etc'
52+
setting AutomountServiceAccountToken to false, will disale auto-mounting, and will allow user to mount
53+
whatever configmaps and tokens he deems necessary for the device plugin application
54+
type: boolean
4855
container:
4956
properties:
5057
args:

config/crd/bases/kmm.sigs.x-k8s.io_modules.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ spec:
4545
DevicePlugin allows overriding some properties of the container that deploys the device plugin on the node.
4646
Name is ignored and is set automatically by the KMM Operator.
4747
properties:
48+
automountServiceAccountToken:
49+
description: |-
50+
AutomountServiceAccountToken is used to disable the auto-mounting of the projected volume
51+
into device plugin pod. This volume includes as files: SA token, CAs' file etc'
52+
setting AutomountServiceAccountToken to false, will disale auto-mounting, and will allow user to mount
53+
whatever configmaps and tokens he deems necessary for the device plugin application
54+
type: boolean
4855
container:
4956
properties:
5057
args:

internal/controllers/device_plugin_reconciler.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -376,14 +376,15 @@ func (dsci *daemonSetCreatorImpl) setDevicePluginAsDesired(
376376
Finalizers: []string{constants.NodeLabelerFinalizer},
377377
},
378378
Spec: v1.PodSpec{
379-
InitContainers: generatePodContainerSpec(mod.Spec.DevicePlugin.InitContainer, "device-plugin-init", nil),
380-
Containers: generatePodContainerSpec(&mod.Spec.DevicePlugin.Container, "device-plugin", containerVolumeMounts),
381-
PriorityClassName: "system-node-critical",
382-
ImagePullSecrets: getPodPullSecrets(mod.Spec.ImageRepoSecret),
383-
NodeSelector: nodeSelector,
384-
ServiceAccountName: serviceAccountName,
385-
Volumes: append([]v1.Volume{devicePluginVolume}, mod.Spec.DevicePlugin.Volumes...),
386-
Tolerations: mod.Spec.Tolerations,
379+
InitContainers: generatePodContainerSpec(mod.Spec.DevicePlugin.InitContainer, "device-plugin-init", nil),
380+
Containers: generatePodContainerSpec(&mod.Spec.DevicePlugin.Container, "device-plugin", containerVolumeMounts),
381+
PriorityClassName: "system-node-critical",
382+
ImagePullSecrets: getPodPullSecrets(mod.Spec.ImageRepoSecret),
383+
NodeSelector: nodeSelector,
384+
ServiceAccountName: serviceAccountName,
385+
Volumes: append([]v1.Volume{devicePluginVolume}, mod.Spec.DevicePlugin.Volumes...),
386+
Tolerations: mod.Spec.Tolerations,
387+
AutomountServiceAccountToken: mod.Spec.DevicePlugin.AutomountServiceAccountToken,
387388
},
388389
},
389390
}

0 commit comments

Comments
 (0)