6

나는 kops를 사용하여 AWS에서 Kubernetes 클러스터를 실행 중입니다. 컨테이너에 EBS 볼륨을 마운트했으며 응용 프로그램에서 볼 수 있지만 응용 프로그램이 루트로 실행되지 않기 때문에 읽기 전용입니다. 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 

더 많은 정보는 여기에 있습니다 : 내 배포 사양에 SecurityContext에 추가 있지만 https://kubernetes.io/docs/concepts/policy/security-context/

+1

예 나는 또한 단지, ​​그것을 알아 냈어. 감사! –

+0

보안 비트를 설정하기위한'volumes. *. defaultMode' 필드에주의하십시오. - https://v1-7.docs.kubernetes.io/docs/concepts/configuration/secret/#using-secrets-as-files-from- 포드 –