Esta documentación es para la versión actual de GKE en AWS, publicada en noviembre de 2021. Consulta las notas de la versión para obtener más información.
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Descripción general
Si ya tienes un volumen de Elastic Block Store (EBS) de AWS para importar a GKE en AWS, puedes crear un objeto PersistentVolume (PV) y reservarlo para un PersistentVolumeClaim (PVC) específico.
En esta página, se explica cómo crear un PV mediante un volumen de EBS existente propagado con datos y cómo usarlo en un Pod. Esta página está dirigida a operadores y especialistas en almacenamiento que desean configurar y administrar el almacenamiento. Para obtener más información sobre los roles comunes y las tareas de ejemplo a las que hacemos referencia en el contenido de Google Cloud , consulta Tareas y roles comunes de los usuarios de GKE.
Antes de comenzar
Antes de completar estos pasos, debes hacer lo siguiente:
Si tu volumen de EBS está encriptado con el servicio de administración de claves (KMS) de AWS, debes otorgar acceso a tu clave de KMS al rol de IAM de AWS del plano de control de AWS de GKE en AWS.
Para otorgar al rol del plano de control acceso a tu clave, sigue estos pasos:
Elige la clave de KMS de AWS que se usa para encriptar el volumen de EBS y agrega el rol del plano de control como un usuario de clave. Para ello, sigue las instrucciones en Permite que los usuarios de clave usen la clave de KMS.
Crea un PersistentVolume para un volumen de EBS preexistente
Puedes importar un volumen de EBS existente si especificas un nuevo PV y lo agregas a tu clúster.
Copia el siguiente YAML en un archivo llamado existing-volume.yaml:
VOLUME_CAPACITY: El tamaño del volumen, por ejemplo, 30G Para obtener más información sobre cómo especificar la capacidad de volumen en Kubernetes, consulta el Significado de memoria.
STORAGE_CLASS_NAME: El nombre de la StorageClass que aprovisiona el volumen, por ejemplo, standard-rwo
EBS_VOLUME_ID: El ID de volumen de EBS
Por ejemplo, vol-05786ec9ec9526b67.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-07-31 (UTC)"],[],[],null,["# Importing a preexisting EBS volume\n\nOverview\n--------\n\nIf you already have an AWS\n[Elastic Block Store (EBS)](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AmazonEBS.html)\nvolume to import into GKE on AWS, you can create a\n[PersistentVolume](https://kubernetes.io/docs/concepts/storage/persistent-volumes/)\n(PV) object and reserve it for a specific PersistentVolumeClaim (PVC).\n\nThis page explains how to create a PV by using an existing EBS volume\npopulated with data, and how to use the PV in a Pod. This page is for\nOperators and Storage specialists who want to configure and\nmanage storage. To learn more about common roles and example tasks that we\nreference in Google Cloud content, see\n[Common GKE user roles and tasks](/kubernetes-engine/enterprise/docs/concepts/roles-tasks).\n\nBefore you begin\n----------------\n\nBefore completing these steps, you must you must:\n\n- [Create a GKE on AWS cluster](/kubernetes-engine/multi-cloud/docs/aws/how-to/create-cluster) and configure access to it with `kubectl`.\n- [Connect and authenticate to your cluster](/kubernetes-engine/multi-cloud/docs/aws/how-to/connect-and-authenticate-to-your-cluster)\n\n### Using encrypted EBS volumes\n\nIf your EBS volume is encrypted with the AWS Key Management Service (KMS), you\nneed to grant the GKE on AWS control plane AWS IAM role access to\nyour KMS key.\n\nTo grant the control plane role access to your key:\n\n1. Find the name of your cluster's\n [control plane role](/kubernetes-engine/multi-cloud/docs/aws/how-to/create-aws-iam-roles#create_the_control_plane_role).\n\n2. Choose the AWS KMS key used to encrypt your EBS volume, and add the control\n plane role as a key user by following the instructions in\n [Allow key users to use the KMS key](https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-default.html#key-policy-default-allow-users).\n\nCreating a PersistentVolume for a pre-existing EBS volume\n---------------------------------------------------------\n\nYou can import an existing EBS volume by specifying a new PV and adding it to\nyour cluster.\n\n1. Copy the following YAML into a file named `existing-volume.yaml`:\n\n apiVersion: v1\n kind: PersistentVolume\n metadata:\n name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eVOLUME_NAME\u003c/span\u003e\u003c/var\u003e\n annotations:\n pv.kubernetes.io/provisioned-by: ebs.csi.aws.com\n spec:\n capacity:\n storage: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eVOLUME_CAPACITY\u003c/span\u003e\u003c/var\u003e\n accessModes:\n - ReadWriteOnce\n persistentVolumeReclaimPolicy: Retain\n storageClassName: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eSTORAGE_CLASS_NAME\u003c/span\u003e\u003c/var\u003e\n claimRef:\n name: my-pvc\n namespace: default\n csi:\n driver: ebs.csi.aws.com\n volumeHandle: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eEBS_VOLUME_ID\u003c/span\u003e\u003c/var\u003e\n fsType: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eFILE_SYSTEM_TYPE\u003c/span\u003e\u003c/var\u003e\n nodeAffinity:\n required:\n nodeSelectorTerms:\n - matchExpressions:\n - key: topology.ebs.csi.aws.com/zone\n operator: In\n values:\n - \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eZONE\u003c/span\u003e\u003c/var\u003e\n\n Replace the following:\n\n - \u003cvar translate=\"no\"\u003eVOLUME_NAME\u003c/var\u003e: The name for your volume.\n - \u003cvar translate=\"no\"\u003eVOLUME_CAPACITY\u003c/var\u003e: size of the volume--- for example, `30G`. For more information on specifying volume capacity in Kubernetes, see the [Meaning of memory](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#meaning-of-memory).\n - \u003cvar translate=\"no\"\u003eSTORAGE_CLASS_NAME\u003c/var\u003e: the name of the StorageClass\n that provisions the volume--- for example, `standard-rwo`.\n\n | **Note:** A StorageClass is required to reference other attributes like `allowVolumeExpansion`, even if a volume is not dynamically provisioned.\n - \u003cvar translate=\"no\"\u003eEBS_VOLUME_ID\u003c/var\u003e: Your EBS\n [volume id](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-volumes.html#examples).\n For example, `vol-05786ec9ec9526b67`.\n\n - \u003cvar translate=\"no\"\u003eFS_TYPE\u003c/var\u003e: The\n [file system](https://github.com/kubernetes-sigs/aws-ebs-csi-driver#createvolume-parameters)\n of the volume--- for example, `ext4`.\n\n - \u003cvar translate=\"no\"\u003eZONE\u003c/var\u003e: The AWS Availability Zone that hosts the\n EBS volume--- for example, `us-east-1c`.\n\n2. Apply the YAML to your cluster\n\n kubectl apply -f existing-volume.yaml\n\n3. Confirm the creation of your PV\n\n kubectl describe pv \u003cvar translate=\"no\"\u003evolume-name\u003c/var\u003e\n\n The output of this command contains the status of the PV.\n\nUsing the volume with a PersistentVolumeClaim and Pod\n-----------------------------------------------------\n\nAfter you have imported your volume, you can create a PVC and a Pod that\nattaches the PVC.\n\n1. The YAML below creates a PVC and attaches it to a Pod running the Nginx web\n server. Copy it into a file named `nginx.yaml`:\n\n apiVersion: v1\n kind: PersistentVolumeClaim\n metadata:\n name: my-pvc\n spec:\n storageClassName: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eSTORAGE_CLASS_NAME\u003c/span\u003e\u003c/var\u003e\n volumeName: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eVOLUME_NAME\u003c/span\u003e\u003c/var\u003e\n accessModes:\n - ReadWriteOnce\n resources:\n requests:\n storage: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eVOLUME_CAPACITY\u003c/span\u003e\u003c/var\u003e\n ---\n\n apiVersion: v1\n kind: Pod\n metadata:\n name: web-server\n spec:\n containers:\n - name: web-server\n image: nginx\n volumeMounts:\n - mountPath: /var/lib/www/html\n name: data\n volumes:\n - name: data\n persistentVolumeClaim:\n claimName: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003ePVC_NAME\u003c/span\u003e\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eSTORAGE_CLASS\u003c/var\u003e: The name of the StorageClass from the PersistentVolume you created previously--- for example, `standard-rwo`.\n - \u003cvar translate=\"no\"\u003eVOLUME_NAME\u003c/var\u003e\n - \u003cvar translate=\"no\"\u003eVOLUME_CAPACITY\u003c/var\u003e\n - \u003cvar translate=\"no\"\u003ePVC_NAME\u003c/var\u003e: Name of the PVC--- for example, `my-pvc`.\n2. Apply the YAML to your cluster\n\n kubectl apply -f nginx.yaml\n\n3. Check the status of your Nginx instance with `kubectl describe`. The output\n should have a `STATUS` of `Running`.\n\n kubectl describe pod web-server\n\nWhat's next\n-----------\n\n- Use additional [storage drivers](/kubernetes-engine/multi-cloud/docs/aws/how-to/storage-drivers) with GKE on AWS."]]