All Products
Search
Document Center

Elastic Container Instance:Increase the capacity of the temporary storage space

Last Updated:Dec 05, 2022

By default, an elastic container instance (pod) provides 30 GiB of storage capacity free of charge. If you need more storage space, you can increase the capacity of the temporary storage space. This topic describes how to increase the capacity of the temporary storage space.

Background information

By default, each elastic container instance provides 30 GiB of temporary storage space free of charge, as shown in the following figure.

Temporary storage space
Important

When an elastic container instance starts, the container image that is used to start the instance consumes the 30 GiB storage quota. The space size of the container environment generated based on the container image is twice of the size of the container image.

If you need more storage space, you can increase the storage capacity of the temporary storage space. You are charged for the increased temporary storage space based on the pay-as-you-go price of performance level-1 (PL1) enhanced SSDs (ESSDs). For more information, see Billing of temporary storage space.

Description

In scenarios in which Kubernetes is used, you can use one of the following methods to increase the capacity of the temporary storage space:

  • Method 1: Add an annotation

    You can use the k8s.aliyun.com/eci-extra-ephemeral-storage field to add an annotation. The field specifies the capacity of the increased temporary storage space.

  • Method 2: Use a resource request

    You can use a resource request to declare the capacity of ephemeral storage for a container. If the declared capacity does not exceed 30 GiB, the capacity of the temporary storage space is not increased. If the declared capacity exceeds 30 GiB, the extra capacity is increased.

Note

Both the preceding methods can be used to increase the capacity of the temporary storage space, but the capacity of the temporary storage space that is increased by using the different methods may be different.

  • When you add an annotation to increase the capacity of the temporary storage space, the capacity of the increased temporary storage space is equal to the value that you specify for the k8s.aliyun.com/eci-extra-ephemeral-storage filed.

  • When you declare the storage space of a container in a resource request, the capacity of the increased temporary storage space may be different from the value that you declare due to the type of the image cache. For more information, see The relationship between the type of the image cache and the capacity of the temporary storage space.

Examples

  1. Prepare a YAML file.

    In the following examples, the YAML file is named extra-storage.yaml. The following examples show the content of the YAML file of the preceding methods:

    • Example 1: Add an annotation

      apiVersion: v1
      kind: Pod
      metadata:
        name: test
        annotations:
          k8s.aliyun.com/eci-extra-ephemeral-storage: "20Gi"  # Specifies the capacity of the increased temporary storage space.
      spec:
        containers:
        - name: nginx
          image: registry-vpc.cn-beijing.aliyuncs.com/eci_open/nginx:1.14.2
          imagePullPolicy: IfNotPresent
        restartPolicy: Always
    • Example 2: Use a resource request

      apiVersion: v1
      kind: Pod
      metadata:
        name: test
      spec:
        containers:
        - name: nginx
          image: registry-vpc.cn-beijing.aliyuncs.com/eci_open/nginx:1.14.2
          imagePullPolicy: IfNotPresent
          resources: 
            requests: 
              ephemeral-storage: 50Gi   # Declares the capacity of the ephemeral storage in the resource request of the container. If the capacity of ephemeral storage exceeds 30 GiB, extra capacity is increased.
        restartPolicy: Always
  2. Create a pod.

    kubectl apply -f extra-storage.yaml
  3. Check whether the temporary storage space takes effect.

    • Check the capacity of the increased temporary storage space.

      kubectl describe pod test | grep k8s.aliyun.com/eci-extra-ephemeral-storage

      The following output indicates that 20 GiB of temporary storage space is increased:

      k8s.aliyun.com/eci-extra-ephemeral-storage: 20Gi
    • Run the exec command to check whether the file system partitions of the container are extended.

      kubectl exec -it test -- sh
      df -h

      The following output indicates that total 50 GiB of storage space (overlay) is available. The total storage space consists of 20 GiB of the increased temporary storage space and 30 GiB of the default storage space.

      Filesystem      Size  Used Avail Use% Mounted on
      overlay          50G  2.1G   48G   5% /
      tmpfs            64M     0   64M   0% /dev
      tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
      /dev/vda4        50G  2.1G   48G   5% /etc/hosts
      shm              64M     0   64M   0% /dev/shm
      tmpfs           4.0G   12K  4.0G   1% /run/secrets/kubernetes.io/serviceaccount
      tmpfs           1.9G     0  1.9G   0% /proc/acpi
      tmpfs           1.9G     0  1.9G   0% /sys/firmware

The relationship between the type of the image cache and the storage capacity of the temporary storage space

The temporary storage space that is generated by the system varies based on the type of the image cache.

  • The temporary storage space of an elastic container instance that is created based on a manual image cache is located on a data disk. You can specify the name of the manual image cache. In this case, the storage capacity of the data disk partition (/dev/disk/by-uuid/****) is equal to the storage capacity of the temporary storage space. The storage capacity of the system disk partition (/dev/vda4) remains the default 30 GiB and is not used. The following figure shows the details.

    Temporary storage space - manual image cache
  • The temporary storage space of an elastic container instance that is created based on an automatic image cache is located on the system disk. The name format of the automatic image cache is auto-create-for-<The ID of the elastic container instance from which the automatic image cache is created>. In this case, the storage capacity of the system disk partition (/dev/vda4) is equal to the storage capacity of the temporary storage space, as shown in the following figure.

    Temporary storage space - automatic image cache