All Products
Search
Document Center

Elastic Container Instance:Scale up the temporary storage space

Last Updated:Feb 23, 2024

By default, the system provides 30 GiB of temporary storage space free of charge to an elastic container instance (pod). If the size of the temporary storage space cannot meet your requirements, you can scale up 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 involved, you can scale up the temporary storage space of a pod by using the following methods:

    Note

    The syntax differences of the methods:

    • Method 1 has the limit syntax. The scaled-up capacity of the temporary storage space is equal to the value that you specify for the k8s.aliyun.com/eci-extra-ephemeral-storage annotation.

    • Method 2 has the request syntax. The scaled-up capacity of the temporary storage space may be different from the value that you specify in the resource request 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.

Method 1: Add an annotation

You can add the k8s.aliyun.com/eci-extra-ephemeral-storage annotation to a pod to scale up the temporary storage space of the pod. The value of the annotation is equal to the scaled-up capacity.

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 specify the capacity of the temporary storage space in the ephemeral-storage field in the resource request. Only if the capacity that you specified exceeds 30 GiB, the temporary storage space is scaled up. The capacity that is scaled up is equal to the capacity that you specify minus 30 GiB.

Configuration examples

  1. Prepare a YAML file.

    For example, if you want to scale up 20 GiB of capacity for the temporary storage space when you create a pod. The YAML file is named extra-storage.yaml. The follow code provides an example of the YAML file.

    • Example 1: Add the annotation

      apiVersion: v1
      kind: Pod
      metadata:
        name: test
        annotations:
          k8s.aliyun.com/eci-extra-ephemeral-storage: "20Gi"  # Specifies the capacity that you want to scale up for the 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: Configure the resource of the container

      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   # Specifies the total capacity of the temporary storage space, which is the sum of the 30 GiB of default capacity and the capacity that you want to scale up.
        restartPolicy: Always
  2. Create a pod.

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

    • Check the scaled-up capacity of the temporary storage space.

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

      The following output indicates that the capacity of the temporary storage space is scaled up by 20 GiB:

      k8s.aliyun.com/eci-extra-ephemeral-storage: 20Gi
    • Run the exec command to log on to the container, and then run the df -h command to check whether the file system partitions of the container are scaled up.

      kubectl exec -it test -- sh
      df -h

      In the following output, the overlay parameter indicates that total 50 GiB of storage space is available. The scaled-up capacity is equal to the total 50 GiB of capacity minus the 30 GiB capacity 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