This documentation is for the most recent version of Anthos clusters on AWS, released on November 3rd. See the Release notes for more information. For documentation on the previous generation of Anthos clusters on AWS, see Previous generation.

Importing a preexisting EBS volume

Stay organized with collections Save and categorize content based on your preferences.


If you already have an AWS Elastic Block Store (EBS)

volume to import into Anthos clusters on AWS, you can create a PersistentVolume (PV) object and reserve it for a specific PersistentVolumeClaim (PVC).

This page explains how to create a PV by using an existing EBS volume populated with data, and how to use the PV in a Pod.

Before you begin

Before completing these steps, you must you must:

Using encrypted EBS volumes

If your EBS volume is encrypted with the AWS Key Management Service (KMS), you need to grant the Anthos clusters on AWS control plane AWS IAM role access to your KMS key.

To grant the control plane role access to your key:

  1. Find the name of your cluster's control plane role.

  2. Choose the AWS KMS key used to encrypt your EBS volume, and add the control plane role as a key user by following the instructions in Allow key users to use the KMS key.

Creating a PersistentVolume for a pre-existing EBS volume

You can import an existing EBS volume by specifying a new PV and adding it to your cluster.

  1. Copy the following YAML into a file named existing-volume.yaml:

    apiVersion: v1
    kind: PersistentVolume
      name: VOLUME_NAME
        storage: VOLUME_CAPACITY
        - ReadWriteOnce
      persistentVolumeReclaimPolicy: Retain
      storageClassName: STORAGE_CLASS_NAME
        name: my-pvc
        namespace: default
        volumeHandle: EBS_VOLUME_ID
        fsType: FILE_SYSTEM_TYPE
          - matchExpressions:
            - key:
              operator: In
              - ZONE
    Replace the following:
    • VOLUME_NAME: The name for your volume.
    • VOLUME_CAPACITY: size of the volume— for example, 30G. For more information on specifying volume capacity in Kubernetes, see the Meaning of memory.
    • STORAGE_CLASS_NAME: the name of the StorageClass that provisions the volume— for example, standard-rwo.

    • EBS_VOLUME_ID: Your EBS volume id. For example, vol-05786ec9ec9526b67.

    • FS_TYPE: The file system of the volume— for example, ext4.

    • ZONE: The AWS Availability Zone that hosts the EBS volume— for example, us-east-1c.

  2. Apply the YAML to your cluster

    kubectl apply -f existing-volume.yaml
  3. Confirm the creation of your PV

    kubectl describe pv volume-name

    The output of this command contains the status of the PV.

Using the volume with a PersistentVolumeClaim and Pod

After you have imported your volume, you can create a PVC and a Pod that attaches the PVC.

  1. The YAML below creates a PVC and attaches it to a Pod running the Nginx web server. Copy it into a file named nginx.yaml:

    apiVersion: v1
    kind: PersistentVolumeClaim
      name: my-pvc
      storageClassName: STORAGE_CLASS_NAME
      volumeName: VOLUME_NAME
        - ReadWriteOnce
          storage: VOLUME_CAPACITY
    apiVersion: v1
    kind: Pod
      name: web-server
       - name: web-server
         image: nginx
           - mountPath: /var/lib/www/html
             name: data
       - name: data
           claimName: PVC_NAME

    Replace the following:

    • STORAGE_CLASS: The name of the StorageClass from the PersistentVolume you created previously— for example, standard-rwo.
    • PVC_NAME: Name of the PVC— for example, my-pvc.
  2. Apply the YAML to your cluster

    kubectl apply -f nginx.yaml
  3. Check the status of your Nginx instance with kubectl describe. The output should have a STATUS of Running.

    kubectl describe pod web-server

What's next