빠른 시작: FUSE CSI 드라이버로 Cloud Storage 버킷에 액세스

이 빠른 시작 가이드에서는 Google Kubernetes Engine (GKE) 애플리케이션 내에서 Cloud Storage 버킷을 로컬 파일 시스템인 것처럼 액세스하는 방법을 알아봅니다. 이 빠른 시작에서는 버킷을 마운트하는 포드를 만드는 샘플 Kubernetes 매니페스트를 제공하고 포드의 파일 시스템을 사용하여 버킷의 콘텐츠와 상호작용하는 방법을 보여줍니다.

이 페이지는 클라우드 리소스를 프로비저닝 및 관리하고 워크로드를 배포하려는 개발자, 스토리지 전문가 및 기타 사용자를 대상으로 합니다. 일반적인 역할에 대해 자세히 알아보려면 일반 GKE 사용자 역할 및 태스크를 참고하세요.

이 페이지를 읽기 전에 KubernetesCloud Storage FUSE CSI 드라이버를 숙지해야 합니다.

이 빠른 시작에서는 GKE Autopilot 모드를 사용합니다. Standard 모드를 사용하려면 GKE용 Cloud Storage FUSE CSI 드라이버 설정을 참고하세요.

시작하기 전에

  1. In the Cloud de Confiance console, on the project selector page, select or create a Cloud de Confiance project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  2. Verify that billing is enabled for your Cloud de Confiance project.

  3. Enable the GKE and Cloud Storage APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the APIs

  4. Make sure that you have the following role or roles on the project: Kubernetes Engine Admin, Storage Admin, Service Account User

    Check for the roles

    1. In the Cloud de Confiance console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.

    4. For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.

    Grant the roles

    1. In the Cloud de Confiance console, go to the IAM page.

      IAM으로 이동
    2. 프로젝트를 선택합니다.
    3. 액세스 권한 부여를 클릭합니다.
    4. 새 주 구성원 필드에 사용자 식별자를 입력합니다. 일반적으로 직원 ID 풀의 사용자 식별자입니다. 자세한 내용은 IAM 정책에서 직원 풀 사용자 표현을 참고하거나 관리자에게 문의하세요.

    5. 역할 선택 목록에서 역할을 선택합니다.
    6. 역할을 추가로 부여하려면 다른 역할 추가를 클릭하고 각 역할을 추가합니다.
    7. 저장을 클릭합니다.
    8. GKE Autopilot 클러스터 만들기

      1. Cloud de Confiance 콘솔에서 Autopilot 클러스터 만들기 페이지로 이동합니다.

        Autopilot 클러스터 만들기로 이동

      2. 클러스터 기본사항에서 다음을 수행합니다.

        1. 이름 필드에 클러스터 이름을 입력합니다.

        2. 나머지 설정은 기본값을 유지합니다.

      3. 만들기를 클릭하여 클러스터를 만듭니다.

      Cloud Storage 버킷 만들기

      1. Cloud de Confiance 콘솔에서 Cloud Storage 버킷 페이지로 이동합니다.

        버킷으로 이동

      2. 만들기를 클릭합니다.

      3. 버킷 만들기 페이지의 시작하기 섹션에서 다음을 수행합니다.

        1. 버킷 이름 지정 요구사항을 충족하는 전역적으로 고유한 버킷 이름을 입력합니다.

        2. 나머지 설정은 기본값을 유지합니다.

      4. 버킷을 만들려면 만들기를 클릭합니다.

      Cloud Storage 버킷에 객체 업로드

      1. Cloud de Confiance 콘솔에서 Cloud Storage 버킷 페이지로 이동합니다.

        버킷으로 이동

      2. 버킷 목록에서 방금 만든 버킷의 이름을 클릭합니다.

      3. 버킷의 객체 탭에서 다음 중 하나를 수행합니다.

        • 바탕화면이나 파일 관리자에서 파일을 Cloud de Confiance 콘솔의 기본 창으로 드래그합니다.

        • 파일 업로드 버튼을 클릭합니다. 표시되는 대화상자에서 업로드할 파일을 선택하고 열기를 클릭합니다.

      Cloud Storage 버킷에 대한 액세스 구성

      GKE 클러스터에서 Cloud Storage 버킷에 액세스할 수 있는지 확인하려면 Cloud Storage 버킷에 대한 액세스 구성의 단계를 따르세요.

      Cloud Shell 설정

      In the Cloud de Confiance console, activate Cloud Shell.

      Activate Cloud Shell

      Cloud Shell 세션이 시작되고 명령줄 프롬프트가 표시됩니다. 세션이 초기화되는 데 몇 초 정도 걸릴 수 있습니다.

      FUSE를 사용하여 Cloud Storage 버킷에 액세스하도록 포드 배포

      1. Pod를 배포할 기본 프로젝트를 설정합니다.

        gcloud config set project PROJECT_ID
        

        PROJECT_ID를 프로젝트 ID로 바꿉니다.

      2. 다음 콘텐츠로 포드 매니페스트를 만들고 적용합니다.

        cat << EOF | kubectl apply -f -
        apiVersion: v1
        kind: Pod
        metadata:
          name: gcsfuse-test
          namespace: default
          annotations:
            gke-gcsfuse/volumes: "true"
        spec:
          terminationGracePeriodSeconds: 60
          containers:
          - image: busybox
            name: busybox
            command: ["sleep"]
            args: ["infinity"]
            volumeMounts:
            - name: gcsfuse-test
              mountPath: /data
              readOnly: true
          serviceAccountName: default
          volumes:
          - name: gcsfuse-test
            csi:
              driver: gcsfuse.csi.storage.gke.io
              volumeAttributes:
                bucketName: BUCKET_NAME
                mountOptions: "implicit-dirs"
        EOF
        
        • BUCKET_NAME을 Cloud Storage 버킷 이름으로 바꿉니다.
        • 다른 네임스페이스 또는 서비스 계정을 사용하는 경우 namespaceserviceAccountName 필드를 적절하게 바꿉니다.

        이 매니페스트의 콘텐츠는 /data 경로에 버킷을 마운트하는 gcsfuse-test라는 포드를 시작합니다.

      3. Pod가 실행 중인지 확인합니다.

        kubectl get pod gcsfuse-test
        

        출력은 다음과 비슷합니다.

        NAME           READY   STATUS    RESTARTS   AGE
        gcsfuse-test   2/2     Running   0          12s
        

        Cloud Storage FUSE CSI 드라이버는 Cloud Storage와의 상호작용을 관리하기 위해 포드에 사이드카 컨테이너를 연결합니다.

        포드가 실행되고 있지 않으면 kubectl describe pod gcsfuse-test 명령어를 실행하여 이벤트 로그를 가져와 문제를 진단할 수 있습니다. 자세한 내용은 GitHub의 문제 해결을 참고하세요.

      4. 포드가 실행된 후 파일 시스템을 탐색할 수 있습니다.

        kubectl exec -it gcsfuse-test -- find /data
        

      삭제

      이 튜토리얼에서 사용한 리소스 비용이 Cloud de Confiance by S3NS 계정에 청구되지 않도록 하려면 포드를 삭제하세요.

      kubectl delete pod gcsfuse-test
      

      다음 단계