Elastic File System(EFS)은 클러스터에 스토리지(디스크 공간)를 제공하기 위한 기본 AWS 메커니즘입니다.
PersistentVolume은 EFS 스토리지를 워크로드에 제공하고 연결된 워크로드가 없을 경우에도 지속되도록 보장하는 클러스터 리소스입니다. 이 주제에서는 워크로드가 PersistentVolumeClaim으로 PersistentVolume에 액세스하는 방법을 설명합니다.
이 페이지는 스토리지를 구성하고 관리하려는 운영자 및 스토리지 전문가를 대상으로 합니다. Google Cloud 콘텐츠에서 참조하는 일반적인 역할 및 예시 태스크에 대해 자세히 알아보려면 일반 GKE 사용자 역할 및 태스크를 참조하세요.
AWS용 GKE는 지원되는 모든 Kubernetes 버전에서 PersistentVolume의 정적 프로비저닝을 지원합니다. Kubernetes 버전 1.24 이상의 클러스터의 경우 AWS용 GKE는 동적 프로비저닝도 지원합니다. 동적 프로비저닝을 사용하려면 클러스터 관리자가 이를 구성해야 합니다. 자세한 내용은 PersistentVolume 구성을 참조하세요.
PersistentVolumeClaim 만들기
워크로드를 정적 또는 동적으로 프로비저닝된 영구 볼륨에 연결할지 여부에 따라 아래에서 적절한 탭을 선택하세요.
정적
이 안내에서는 클러스터 관리자가 이미 하나 이상의 PersistentVolume을 프로비저닝했다고 가정합니다. 이 PersistentVolume에 액세스하고 워크로드에 기본 EFS를 사용하려면 PersistentVolumeClaim을 만듭니다.
정적으로 프로비저닝된 PersistentVolume에 대해 PersistentVolumeClaim을 만들려면 다음 YAML 매니페스트를 efs-claim.yaml이라는 파일에 복사합니다.
apiVersion:v1kind:PersistentVolumeClaimmetadata:name:CLAIM_NAMEspec:accessModes:-ReadWriteManystorageClassName:""# Leave as empty string for static provisioningresources:requests:storage:5Gi
이 안내에서는 클러스터 관리자가 동적 프로비저닝을 위해 이미 하나 이상의 StorageClass를 프로비저닝했다고 가정합니다. 이 StorageClass를 사용하여 동적으로 프로비저닝된 PersistentVolume을 만들고 워크로드에서 기본 EFS 액세스 포인트를 사용하려면 PersistentVolumeClaim을 만듭니다.
PersistentVolumeClaim을 만들려면 다음 단계를 수행합니다. EFS CSI 드라이버는 표시된 StorageClass와 함께 이 PersistentVolumeClaim을 사용해서 PersistentVolume을 동적으로 프로비저닝합니다.
CLAIM_NAME: PersistentVolumeClaim에 대해 선택한 이름(예: efs-claim1)입니다.
EFS_STORAGE_CLASS_NAME: PersistentVolumeClaim을 바인딩하려는 StorageClass의 이름입니다. 기본 스토리지 클래스에 바인딩하려면 이 필드를 비워 두세요.
YAML을 클러스터에 적용합니다.
kubectlapply-fefs-claim.yaml
출력에서 PersistentVolumeClaim의 생성을 확인합니다.
persistentvolumeclaim/CLAIM_NAME created
StatefulSet 만들기
PersistentVolumeClaim을 만든 후 워크로드에서 사용할 수 있습니다.
이 섹션에서는 PersistentVolumeClaim을 사용하는 샘플 StatefulSet를 만듭니다.
spec.volumes에서 클레임을 참조하여 포드 및 배포와 같은 다른 워크로드 유형과 함께 PersistentVolumeClaim을 사용할 수도 있습니다.
PersistentVolumeClaim에서 참조되는 EFS 리소스를 마운트하는 StatefulSet를 만들려면 다음 단계를 수행합니다.
다음 YAML 매니페스트를 efs-statefulset.yaml이라는 파일에 복사합니다.
이 예시 매니페스트는 /efs-data에 EFS 리소스를 마운트하는 Ubuntu Linux 컨테이너를 실행합니다. 컨테이너는 5초마다 out.txt라는 EFS 리소스의 파일에 씁니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[],[],null,["# Use an EFS resource\n\nThe [Elastic File System](https://aws.amazon.com/efs/) (EFS) is the\nunderlying AWS mechanism for providing storage (disk space) to your cluster.\nA PersistentVolume is a cluster resource that makes EFS\nstorage available to your workloads and ensures that it persists even when no\nworkloads are connected to it. This topic describes how a workload can access a\nPersistentVolume with a PersistentVolumeClaim.\n\nThis page is for Operators and Storage specialists who want to\nconfigure and manage storage. To learn more about common roles and example tasks\nthat we reference in Google Cloud content, see\n[Common GKE user roles and tasks](/kubernetes-engine/enterprise/docs/concepts/roles-tasks).\n\nGKE on AWS supports static provisioning of PersistentVolumes for all\nsupported Kubernetes versions. For clusters at Kubernetes version 1.24 or\nlater, GKE on AWS also supports dynamic provisioning. To use dynamic\nprovisioning, your cluster administrator must configure it. To learn how, see\n[configure a `PersistentVolume`](/kubernetes-engine/multi-cloud/docs/aws/how-to/configure-efs).\n| **Note:** Dynamic provisioning is available in GKE on AWS as a preview feature. Contact Google Cloud your support team for access.\n\nCreate a PersistentVolumeClaim\n------------------------------\n\nChoose the appropriate tab below depending on whether you want your workload to\nconnect to a statically or dynamically-provisioned persistent volume. \n\n### Static\n\nThese instructions assume that your cluster administrator has already provisioned\nat least one PersistentVolume. To access this PersistentVolume and use its\nunderlying EFS with your workloads, create a PersistentVolumeClaim.\n\nTo create a PersistentVolumeClaim for a statically-provisioned PersistentVolume,\ncopy the following YAML manifest into a file named `efs-claim.yaml`. \n\n apiVersion: v1\n kind: PersistentVolumeClaim\n metadata:\n name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eCLAIM_NAME\u003c/span\u003e\u003c/var\u003e\n spec:\n accessModes:\n - ReadWriteMany\n storageClassName: \"\" # Leave as empty string for static provisioning\n resources:\n requests:\n storage: 5Gi\n\nReplace:\n\n- \u003cvar translate=\"no\"\u003eCLAIM_NAME\u003c/var\u003e: a name you choose for your PersistentVolumeClaim to bind to - for example, `efs-claim1`. Leave blank to bind to the default storage class\n\n| **Note:** You must use the same `storageClassName` value for your PersistentVolume and PersistentVolumeClaim resources.\n\n1. Apply the YAML to your cluster.\n\n kubectl apply -f efs-claim.yaml\n\n This output confirms the PersistentVolumeClaim's creation. \n\n persistentvolumeclaim/\u003cvar translate=\"no\"\u003eCLAIM_NAME\u003c/var\u003e created\n\n### Dynamic\n\nThese instructions assume that your cluster administrator has already\nprovisioned at least one StorageClass for dynamic provisioning. To create a\ndynamically-provisioned PersistentVolume with this StorageClass and use the\nunderlying EFS access point with your workloads, create a PersistentVolumeClaim.\n\nTo create a PersistentVolumeClaim, follow these steps. The EFS CSI driver uses\nthis PersistentVolumeClaim with the indicated StorageClass to dynamically\nprovision a PersistentVolume.\n\n1. Copy the following YAML manifest into a file named `efs-claim.yaml`.\n\n apiVersion: v1\n kind: PersistentVolumeClaim\n metadata:\n name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eCLAIM_NAME\u003c/span\u003e\u003c/var\u003e\n spec:\n accessModes:\n - ReadWriteMany\n storageClassName: \"\u003cvar translate=\"no\"\u003eEFS_STORAGE_CLASS_NAME\u003c/var\u003e\"\n resources:\n requests:\n storage: 5Gi\n\nReplace:\n\n- \u003cvar translate=\"no\"\u003eCLAIM_NAME\u003c/var\u003e: a name you choose for your PersistentVolumeClaim - for example, `efs-claim1`\n- \u003cvar translate=\"no\"\u003eEFS_STORAGE_CLASS_NAME\u003c/var\u003e: the name of the StorageClass you want your PersistentVolumeClaim to bind to. Leave this field blank to bind to the default storage class\n\n1. Apply the YAML to your cluster.\n\n kubectl apply -f efs-claim.yaml\n\n The output confirms the PersistentVolumeClaim's creation. \n\n persistentvolumeclaim/\u003cvar translate=\"no\"\u003eCLAIM_NAME\u003c/var\u003e created\n\nCreate a StatefulSet\n--------------------\n\nAfter you have created a PersistentVolumeClaim, you can use it in a workload.\nThis section creates a sample StatefulSet that uses a PersistentVolumeClaim.\nYou can also use a PersistentVolumeClaim with other workload types\nsuch as Pods and Deployments by referencing the claim in `spec.volumes`.\n\nTo create a StatefulSet that mounts the EFS resource referenced in your\nPersistentVolumeClaim, perform the following steps.\n\n1. Copy the following YAML manifest into a file named `efs-statefulset.yaml`.\n This example manifest launches an Ubuntu Linux container that mounts your\n EFS resource at `/efs-data`. The container writes every five seconds to a\n file on your EFS resource named `out.txt`.\n\n apiVersion: apps/v1\n kind: StatefulSet\n metadata:\n name: efs-shell\n spec:\n selector:\n matchLabels:\n app: test-efs\n serviceName: efs-app\n replicas: 1\n template:\n metadata:\n labels:\n app: test-efs\n spec:\n terminationGracePeriodSeconds: 10\n containers:\n - name: linux\n image: ubuntu:bionic\n command: [\"/bin/sh\"]\n args: [\"-c\", \"while true; do echo $(date -u) \u003e\u003e /efs-data/out.txt; sleep 5; done\"]\n volumeMounts:\n - name: efs-volume\n mountPath: /efs-data\n volumes:\n - name: efs-volume\n persistentVolumeClaim:\n claimName: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eCLAIM_NAME\u003c/span\u003e\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eCLAIM_NAME\u003c/var\u003e with the name of the PersistentVolumeClaim\n you specified previously - for example, `efs-claim1`.\n2. Apply the YAML to your cluster.\n\n kubectl apply -f efs-statefulset.yaml\n\n The output confirms the StatefulSet's creation. \n\n statefulset.apps/efs-shell created\n\n The StatefulSet might take several minutes to download and launch the container\n image.\n3. Confirm the StatefulSet's Pod is in `Running` status with `kubectl get pods`.\n\n kubectl get pods -l app=test-efs\n\n The output includes the name of the Pod and its status. In the following\n response, the Pod's name is `efs-shell-0`. \n\n NAME READY STATUS RESTARTS AGE\n efs-shell-0 1/1 Running 0 1m\n\n4. After the Pod is in Running status, use `kubectl exec` to connect to\n the Pod hosting the StatefulSet.\n\n kubectl exec -it efs-shell-0 -- bash\n\n The `kubectl` command launches a shell on the Pod.\n5. To confirm that your EFS resource is mounted, check the contents of\n the `out.txt` file with the `tail` command.\n\n tail /efs-data/out.txt\n\n The output contains recent times in UTC.\n6. Disconnect from the Pod with the `exit` command.\n\n exit\n\n Your shell returns to your local machine.\n\nClean up\n--------\n\nTo remove the StatefulSet, use `kubectl delete`. \n\n kubectl delete -f efs-statefulset.yaml\n\nWhat's next\n-----------\n\n- Learn how to [configure an EFS resource](/kubernetes-engine/multi-cloud/docs/aws/how-to/configure-efs)\n- Learn how to [use StorageClasses with your workloads](/kubernetes-engine/multi-cloud/docs/aws/how-to/storage-class)"]]