By default, each ACS pod provides 30 GiB of free ephemeral storage space (EphemeralStorage). You can expand the storage space if the default size does not meet your business requirement.
Background information
By default, each ACS pod provides 30 GiB of free ephemeral storage space, as displayed in the following figure.
The container image used by the ACS pod is stored in the ephemeral storage space. The ephemeral storage space occupied by the container image is at least two times the size of the container image. The actual space usage depends on the compression ration of the container image.
Billing
When the EphemeralStorage exceeds 30 GiB, the overage is billed based on the billing rules of disks.
Fee = Unit price of disks × Ephemeral storage overage × Duration.
Unit price of disks: the pay-as-you-go price of PL1 ESSDs. For more information about the unit prices of disks in different regions, see EBS pricing.
Ephemeral storage overage: the additional storage space that you declared.
Duration: the duration that is measured in seconds. The EphemeralStorage is created and released together with the ACS pod and its uptime equals the uptime of the ACS pod.
How to configure
ACS allows you to use the following two methods to add the EphemeralStorage to an ACS pod.
Method 1 (recommended): Add an annotation
You can add the
alibabacloud.com/extra-ephemeral-storage
annotation when creating an ACS pod to declare the size of the EphemeralStorage.Method 2: Configure the container resource
You can declare the size of the EphemeralStorage in
.resources.requests.ephemeral-storage
of the ACS pod when creating the pod. If the EphemeralStorage size is smaller 30 GiB, the actual EphemeralStorage is automatically expanded to 30 GiB. If the EphemeralStorage size exceeds 30 GiB, the overage is the additional storage space.
Examples
For example, you want to add 20 GiB of ephemeral storage space to an ACS pod. In this case, EphemeralStorage = Default 30 GiB + Additional 20 GiB = 50 GiB.
Create a YAML file named extra-storage.yaml based on the following content.
Method 1: Add an annotation
apiVersion: apps/v1 kind: Deployment metadata: name: test labels: app: nginx spec: replicas: 1 selector: matchLabels: app: nginx template: metadata: labels: app: nginx annotations: alibabacloud.com/extra-ephemeral-storage: "20Gi" # Declare the additional storage space. spec: containers: - name: nginx image: registry.cn-hangzhou.aliyuncs.com/acs-sample/nginx:latest ports: - containerPort: 80
Method 2: Configure the container resource
apiVersion: apps/v1 kind: Deployment metadata: name: test labels: app: nginx spec: replicas: 1 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: registry.cn-hangzhou.aliyuncs.com/acs-sample/nginx:latest ports: - containerPort: 80 resources: requests: ephemeral-storage: 50Gi # Declare the size of the EphemeralStorage.
Create a workload.
kubectl apply -f extra-storage.yaml
View the pod deployment.
kubectl get pod
Expected output:
NAME READY STATUS RESTARTS AGE test-ff8767b7b-**** 1/1 Running 0 54s
Check whether the EphemeralStorage takes effect.
View the pod annotation to confirm the size of the EphemeralStorage.
The value of
alibabacloud.com/pod-ephemeral-storage
indicates the ephemeral storage space of the ACS pod in GiB.kubectl describe pod test-ff8767b7b-**** | grep alibabacloud.com/pod-ephemeral-storage
The output indicates that the size of the EphemeralStorage is 50 GiB.
alibabacloud.com/pod-ephemeral-storage: 50Gi
Run the
exec
command to log on to a container and then run thedf -h
command to check whether the file system partition is expanded.kubectl exec -it test-ff8767b7b-**** -- sh df -h
The output indicates that the actual available storage space (overlay) is 50 GiB.
Filesystem Size Used Avail Use% Mounted on overlay 50G 2.7G 45G 6% / tmpfs 64M 0 64M 0% /dev tmpfs 2.8G 0 2.8G 0% /sys/fs/cgroup /dev/vda5 50G 2.7G 45G 6% /etc/hosts shm 64M 0 64M 0% /dev/shm tmpfs 4.0G 12K 4.0G 1% /run/secrets/kubernetes.io/serviceaccount tmpfs 2.8G 0 2.8G 0% /proc/acpi tmpfs 2.8G 0 2.8G 0% /proc/scsi tmpfs 2.8G 0 2.8G 0% /sys/firmware