In today's containerd cri, in the case of privileged container, cri adds all host devices and ignore the device mapping when PrivilegedWithoutHostDevices is false(default value). Otherwise, cri only adds configured device mapping.
|
if !ociRuntime.PrivilegedWithoutHostDevices { |
|
specOpts = append(specOpts, oci.WithHostDevices, oci.WithAllDevicesAllowed) |
|
} else { |
|
// add requested devices by the config as host devices are not automatically added |
|
specOpts = append(specOpts, customopts.WithDevices(c.os, config), customopts.WithCapabilities(securityContext)) |
|
} |
But the device mapping should be honored even in privileged mode.
Steps to reproduce the issue:
I didn't find an easy way to produce because ctr --device flag doesn't support device mapping. See #5046
- Start a k8s cluster
- Create a PersistentVolume with volumeMode as Block
- Create a PersistentVolumeClaim with volumeMode as Block. (You should see the PersistentVolumeClaim is bound with PersistentVolume)
- Create a Pod with volume corresponding to the PersistentVolumeClaim and specify a devicePath
apiVersion: v1
kind: Pod
spec:
containers:
securityContext:
privileged: true
volumeDevices:
devicePath: /my-disk
name: example-local-claim
volumes:
name: example-local-claim
persistentVolumeClaim:
claimName: example-local-claim
- exec into the pod
Describe the results you received:
- /dev/ has all the host devices
- /my-disk doesn't exist
Describe the results you expected:
- /dev/ has all the host devices
- /my-disk exist
Output of containerd --version:
containerd github.com/containerd/containerd v1.5.0-beta.1-2-gddcc431c1.m ddcc431c11b80aacf495dbcf920fe46f7d748345.m
Any other relevant information:
In today's containerd cri, in the case of privileged container, cri adds all host devices and ignore the device mapping when PrivilegedWithoutHostDevices is false(default value). Otherwise, cri only adds configured device mapping.
containerd/pkg/cri/server/container_create_linux.go
Lines 216 to 221 in b3f2402
But the device mapping should be honored even in privileged mode.
Steps to reproduce the issue:
I didn't find an easy way to produce because ctr --device flag doesn't support device mapping. See #5046
Describe the results you received:
Describe the results you expected:
Output of
containerd --version:Any other relevant information:
--deviceworks at privileged mode moby/moby#40291