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-一莢 –

相關問題