6

我在AWS上使用kops运行Kubernetes集群。我已经将一个EBS卷装载到一个容器上,并且它可以从我的应用程序中看到,但它是只读的,因为我的应用程序没有以root身份运行。我如何将一个PersistentVolumeClaim作为root以外的用户进行安装? VolumeMount似乎没有任何选项来控制装入路径的用户,组或文件权限。Kubernetes:如何设置VolumeMount用户组和文件权限

这里是我的部署YAML文件:

apiVersion: extensions/v1beta1 
kind: Deployment 
metadata: 
    name: notebook-1 
spec: 
    replicas: 1 
    template: 
    metadata: 
     labels: 
     app: notebook-1 
    spec: 
     volumes: 
     - name: notebook-1 
     persistentVolumeClaim: 
      claimName: notebook-1 
     containers: 
     - name: notebook-1 
     image: jupyter/base-notebook 
     ports: 
     - containerPort: 8888 
     volumeMounts: 
     - mountPath: "/home/jovyan/work" 
      name: notebook-1 

回答

5

荚安全上下文支持设置一个fsGroup,它允许您设置拥有该卷组ID,因此谁能够写入。在文档中的例子:在这个

apiVersion: v1 
kind: Pod 
metadata: 
    name: hello-world 
spec: 
    containers: 
    # specification of the pod's containers 
    # ... 
    securityContext: 
    fsGroup: 1234 

更多信息是在这里:https://kubernetes.io/docs/concepts/policy/security-context/

+1

是的,我也只是想通了这一点,虽然我说的SecurityContext我的部署规范。谢谢! –

+0

也注意'volumes。*。defaultMode'字段设置安全位 - https://v1-7.docs.kubernetes.io/docs/concepts/configuration/secret/#using-secrets-as-files-from-一荚 –

相关问题