我在部署中使用了nfs安装的音量。我需要将其提供给以下的FSGroup:
securityContext:
runAsUser: 1000
runAsGroup: 3000
fsGroup: 2000
有没有办法在部署清单上做到这一点?正如我在文档上看到的,我只能在pod yaml中设置SecurityContext。
您可以在Deployment
中使用securityContext
,就像在Pod
中使用它一样使用它。
就像已经在template.spec
下放置了它:
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-deployment
labels:
app: test
spec:
replicas: 3
selector:
matchLabels:
app: test
template:
metadata:
labels:
app: test
spec:
securityContext:
runAsUser: 2000
runAsGroup: 3000
fsGroup: 2000
containers:
- name: test
image: busybox
ports:
- containerPort: 80
command: [ "sh", "-c", "sleep 1h" ]
您可以测试:
$ kubectl exec -it test-deployment-54d954d7f-2b582 sh
/ $ ps
PID USER TIME COMMAND
1 2000 0:00 sleep 1h
6 2000 0:00 sh
11 2000 0:00 ps
/ $ whoami
whoami: unknown uid 200