권한 오류로 인해 내 File Storage for VPC 배치가 실패하는 이유는 무엇입니까?
가상 사설 클라우드
File Storage for VPC 를 사용하는 앱에서 권한 오류로 인해 실행에 실패합니다.
VPC 파일 스토리지에서 비루트 사용자 액세스 문제를 해결합니다.
기존 파일 공유와 함께 사용할 사용자 고유의 스토리지 클래스를 작성했지만 올바른 uid 및 gid 를 지정하지 않았습니다. UNIX 및 Linux 에서 프로세스가 실행될 때, 운영 체제는 사용자를 사용자 ID(UID)로, 그룹을 그룹 ID(GID)로 식별합니다. 이러한 ID는 사용자 또는 그룹에서 액세스할 수 있는 시스템 자원을 판별합니다. 예를 들어, 파일 저장소의 사용자 ID가 12345이고
그룹 ID가 6789인 경우, 호스트 노드와 컨테이너 내의 마운트 지정은 동일한 ID를 가져야 합니다. 컨테이너의 기본 프로세스는 파일 공유에 액세스하기 위해 해당 ID 중 하나 또는 둘 다와 일치해야 합니다.
다음 방법 중 하나를 통해 이 문제를 해결할 수 있습니다.
-
앱을 비루트로 실행해야 하는 경우 앱에 필요한 올바른
uid및gid를 사용하여 자체 스토리지 클래스를 작성하십시오. -
앱을 루트 사용자로 실행하려면, 배포 설정을 수정하여
fsGroup: 0``를 사용하도록 하세요.
자체 스토리지 클래스를 작성하고 앱에 필요한 uid 및 gid 를 지정하십시오.
정적 프로비저닝과 함께 File Storage for VPC 를 사용하려면 올바른 uid 및 gid 를 참조해야 합니다.
-
앱에 필요한 올바른
uid및gid로 스토리지 클래스를 작성하십시오. 스토리지 프로필 목록은 File Storage for VPC 프로필을 참조하세요.apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: custom-storageclas provisioner: vpc.file.csi.ibm.io mountOptions: - hard - nfsvers=4.0 - sec=sys parameters: profile: "custom-iops" # The VPC Storage profile used. iops: "400" # Default IOPS. User can override from secrets billingType: "hourly" # The default billing policy used. User can override this default encrypted: "false" # By default, all PVC using this class will only be provider managed encrypted. The user can override this default encryptionKey: "" # If encrypted is true, then a user must specify the encryption key used associated KP instance resourceGroup: "" # Use resource group if specified here. Otherwise, use the one mentioned in storage-secrete-store zone: "" # By default, the storage vpc driver will select a zone. The user can override this default tags: "" # A list of tags "a, b, c" that will be created when the volume is created. This can be overidden by user classVersion: "1" uid: "1234" # The initial user identifier for the file share. gid: "5678" # The initial group identifier for the file share. reclaimPolicy: "Delete" allowVolumeExpansion: true -
클러스터에 사용자 정의된 스토리지 클래스를 작성하십시오.
oc apply -f custom-storageclass.yaml -
클러스터에서 스토리지 클래스가 사용 가능한지 확인하십시오.
oc get sc출력 예
NAME PROVISIONER ibmc-vpc-file-10iops-tier vpc.file.csi.ibm.io ibmc-vpc-file-3iops-tier vpc.file.csi.ibm.io ibmc-vpc-file-5iops-tier vpc.file.csi.ibm.io ibmc-vpc-file-retain-10iops-tier vpc.file.csi.ibm.io ibmc-vpc-file-retain-3iops-tier vpc.file.csi.ibm.io ibmc-vpc-file-retain-5iops-tier vpc.file.csi.ibm.io ibmc-vpc-file-custom vpc.file.csi.ibm.io
fsGroup: 0 를 사용하여 루트로 실행되도록 앱을 편집하십시오.
-
클러스터에 로그인하십시오.
-
클러스터에서 편집할 배치를 식별하십시오.
kubectl get deployments -
배치의
securityContext섹션에서fsGroup: 0를 추가하여 배치를 편집하십시오.kubectl get deployment -o yaml YOUR-DEPLOYMENTapiVersion: apps/v1 kind: Deployment metadata: name: <deployment_name> labels: app: <deployment_label> spec: securityContext: fsGroup: 0 selector: matchLabels: app: <app_name> template: metadata: labels: app: <app_name> spec: containers: - image: <image_name> name: <container_name> volumeMounts: - name: <volume_name> mountPath: /<file_path> volumes: - name: <volume_name> persistentVolumeClaim: claimName: PVC-NAME -
배치에 변경사항을 적용하십시오.