All Products
Search
Document Center

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

Last Updated:Nov 29, 2023

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

The container image that is used to start an elastic container instance occupies the free 30 GiB temporary storage space. The size of the space that a container image needs to occupy is at least twice the size of the container image and determined by the compression ratio of the image.

If you need a storage space of more than 30 GiB, you can increase the capacity of the temporary storage space. You are charged for the increased temporary storage space based on its capacity and usage duration. For more information, see Billing of the temporary storage space.

Configuration 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 add the k8s.aliyun.com/eci-extra-ephemeral-storage annotation to specify the increased capacity of the temporary storage space.

    Important
    • Annotations must be added to the metadata in the configuration file of the pod. For example, when you create a Deployment, you must add annotations in the spec.template.metadata section.

    • To use features of Elastic Container Instance, you can add annotations only when you create Elastic Container Instance-based pods. If you add or modify annotations when you update pods, these annotations do not take effect.

  • 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.

  • If you use both methods, the greater value configured in the methods takes effect.

Configuration 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 files 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 log on to the container, and run the df -h 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 capacity of the temporary storage space

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

  • If an elastic container instance is created based on a manual image cache, the temporary storage space of the instance is located on a data disk. You can specify the name of the manual image cache. In this case, the capacity of the data disk partition (/dev/disk/by-uuid/****) is equal to the capacity of the temporary storage space. The 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

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

    Temporary storage space - automatic image cache