Skip to content

Commit 8349c46

Browse files
committed
remove privileged permission requirment
Signed-off-by: bingshen.wbs <[email protected]>
1 parent 671b076 commit 8349c46

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

deploy/helm/templates/daemonset.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ spec:
2727
containers:
2828
- name: {{ .Chart.Name }}
2929
securityContext:
30-
privileged: true
30+
capabilities:
31+
add:
32+
- SYS_MODULE
33+
- SYS_ADMIN
34+
- NET_ADMIN
35+
- SYS_PTRACE
3136
command:
3237
- /usr/local/bin/agent
3338
{{ if .Values.agent.preferDriver }}
@@ -59,7 +64,7 @@ spec:
5964
- mountPath: /var/lib/kubelet/pod-resources/
6065
name: pod-resource-dir
6166
- mountPath: /var/run/
62-
name: docker
67+
name: var-run
6368
volumes:
6469
- name: pod-resource-dir
6570
hostPath:
@@ -70,10 +75,12 @@ spec:
7075
- name: cri-dir
7176
hostPath:
7277
path: /run/containerd
78+
type: "Directory"
7379
- name: device-plugin
7480
hostPath:
7581
path: /var/lib/kubelet/device-plugins
76-
- name: docker
82+
type: "Directory"
83+
- name: var-run
7784
hostPath:
7885
path: /var/run/
7986
{{- with .Values.nodeSelector }}

internal/deviceplugin/deviceplugin.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ func (m *ERDMADevicePlugin) PreStartContainer(ctx context.Context, req *pluginap
143143
}
144144
return nil
145145
}
146+
ensureSysctlFSRW, err := exec.Command("bash", "-c",
147+
"mount | grep ' /proc/sys ' | grep rw || mount -o remount,rw /proc/sys").CombinedOutput()
148+
if err != nil {
149+
return nil, fmt.Errorf("can not ensure sysctl fs rw permission %s, err: %v", ensureSysctlFSRW, err)
150+
}
151+
146152
err = configSysctl("net.smc.tcp2smc=1")
147153
if err != nil {
148154
return &pluginapi.PreStartContainerResponse{}, err

0 commit comments

Comments
 (0)