All Products
Search
Document Center

Auto Scaling:List of supported YAML fields and annotations

Last Updated:May 30, 2024

Before you use Kubernetes Deployments in YAML format to create scaling groups, you must understand the supported YAML fields and annotations. This helps you tailor your YAML configurations to suit your business requirements.

Supported YAML fields

When you use a Kubernetes YAML Deployment to deploy a scaling group of the Elastic Container Instance type, you can configure only the following YAML fields:

Note

A YAML field typically consists of kind, metadata, and spec. You can refer to the sample Deployment at the Kubernetes official website to learn more about the YAML file structure.

Supported Kubernetes YAML fields

  • kind: the resource type. Set the value to Deployment.

  • metadata.name: the resource name. This field does not take effect on the scaling group that you want to create. You can use annotation k8s.aliyun.com/ess-scaling-group-name to specify a scaling group name.

  • spec.replicas: the number of pod replicas, which is also the expected number of container instances in the scaling group that you want to create.

  • spec.template.spec: the pod configurations. The following table describes the supported features.

    Feature

    YAML field

    Description

    DNS

    dnsPolicy

    The Domain Name System (DNS) policy.

    dnsConfig.nameservers

    The IP addresses of the DNS servers.

    dnsConfig.searches

    The search domains of the DNS servers.

    dnsConfig.options.name

    The option key.

    dnsConfig.options.value

    The option value.

    Container

    contaners.name

    The container name.

    contaners.image

    The container image.

    contaners.command

    The startup command of the container.

    contaners.args

    The startup arguments of the container.

    contaners.imagePullPolicy

    The image pulling policy of the container.

    contaners.stdin

    Specifies whether to allocate buffer resources for stdin.

    contaners.stdinOnce

    Specifies whether to allocate one-time buffer resources for stdin.

    contaners.tty

    Specifies whether to allocate a TeleTYpe (TTY) for each container.

    contaners.ports

    containerPort

    The port number.

    protocol

    The TCP or UDP protocol.

    contaners.env

    name

    The name of the environment variable.

    value

    The value of the environment variable.

    contaners.resources

    requests.cpu

    The requested CPU resources.

    requests.memory

    The requested memory resources.

    limits.cpu

    The upper limit of resource usage.

    limits.memory

    The upper limit of memory usage.

    limits.nvidia.com/gpu

    The requested GPU resources. You can add annotations to the metadata section in the pod configuration file to specify GPU specifications.

    Then, you must add the nvidia.com/gpu field to the resources section where you define configurations for containers.

    contaners.securityContext

    runAsUser

    The ID of the user who runs the container.

    readOnlyRootFilesystem

    Specifies whether the root file system on which the container runs is read-only.

    capabilities.add

    Adds specific permissions to processes running in the container.

    contaners.volumeMounts

    name

    The volume that you want to mount to the container. The value of this field must match the custom name of the desired volume.

    mountPath

    The mount path of the volume in the container.

    mountPropagation

    The mount propagation settings of the container.

    readOnly

    Valid values:

    • true: The volume is mounted in read-only mode.

    • false: The volume is mounted in read/write mode.

    Default value: false.

    subPath

    The sub-path of the volume.

    contaners.livenessProbe

    • initialDelaySeconds

    • periodSeconds

    • successThreshold

    • timeoutSeconds

    • failureThreshold

    • exec.command

    • tcpSocket.port

    • httpGet.scheme

    • httpGet.port

    • httpGet.path

    The configurations for liveness, readiness, and startup probes.

    contaners.readinessProbe

    • initialDelaySeconds

    • periodSeconds

    • successThreshold

    • timeoutSeconds

    • failureThreshold

    • exec.command

    • tcpSocket.port

    • httpGet.scheme

    • httpGet.port

    • httpGet.path

    init container

    initContainers.name

    The name of the init container.

    initContainers.image

    The image of the init container.

    initContainers.command

    The startup command of the init container.

    initContainers.args

    The startup arguments of the init container.

    initContainers.imagePullPolicy

    The image pulling policy of the init container.

    initContainers.env

    name

    The name of the environment variable used by the init container.

    value

    The value of the environment variable used by the init container.

    initContainers.resources

    requests.cpu

    The CPU resources requested by the init container.

    requests.memory

    The memory resources requested by the init container.

    limits.cpu

    The upper limit of CPU usage for the init container.

    limits.memory

    The upper limit of memory usage for the init container.

    limits.nvidia.com/gpu

    The GPU resources requested by the init container.

    initContainers.securityContext

    capabilities.add

    Adds specific permissions to specific processes running in the init container.

    initContainers.volumeMounts

    name

    The volume that you want to mount to the init container. The value of this field must match the custom name of the desired volume.

    mountPath

    The mount path of the volume in the init container.

    mountPropagation

    The mount propagation settings of the init container.

    readOnly

    Valid values:

    • true: The volume is mounted in read-only mode.

    • false: The volume is mounted in read/write mode.

    Default value: false.

    subPath

    The sub-path of the volume.

    Volume

    volumes.nfs

    name

    The custom name of the volume.

    server

    The endpoint of the Network File System (NFS) server, which is also the mount target of the NAS file system.

    path

    The path to the NFS volume.

    readOnly

    Specifies whether the volume is read-only.

    volumes.emptyDir

    sizeLimit

    The size of the emptyDir volume. Unit: GiB or MiB.

    medium

    The storage medium of the emptyDir volume. Valid values:

    • If you do not configure this field or set the value to null, the node file system is used as the storage medium.

    • If you set the value to memory, the memory is used as the storage medium.

    By default, this field is left empty.

    volumes.flexVolume

    driver

    The driver name of the FlexVolume.

    options

    The options of the FlexVolume. Each option is a key-value pair in a JSON string.

    If you want to mount a FlexVolume, specify the options in the {"volumeId":"d-2zehdahrwoa7srg****","performanceLevel": "PL2"} format.

    Graceful shutdown

    terminationGracePeriodSeconds

    The buffer period during which a program handles operations before the program is stopped. Unit: seconds.

Supported annotations

When you use a Kubernetes YAML Deployment to deploy a scaling group of the Elastic Container Instance type, you can configure only the following annotations:

Supported annotations

Annotation

Example

Description

k8s.aliyun.com/ess-scaling-group-min-size

1

The minimum size of the scaling group. Default value: 0.

k8s.aliyun.com/ess-scaling-group-max-size

20

The maximum size of the scaling group. Default value: max(replicas, 30).

k8s.aliyun.com/eci-ntp-server

100.100.*.*

The IP address of the Network Time Protocol (NTP) server.

k8s.aliyun.com/eci-use-specs

2-4Gi

The specification for elastic container instances. You can specify multiple specifications. For more information, see Create pods by specifying multiple specifications.

k8s.aliyun.com/eci-vswitch

vsw-bp1xpiowfm5vo8o3c****

The vSwitch ID. You can specify multiple vSwitch IDs to ensure that container instances can be created in zones in which sufficient resources exist.

k8s.aliyun.com/eci-security-group

sg-bp1dktddjsg5nktv****

The ID of the security group. The following requirements must be met:

  • You can assign up to five security groups.

  • The assigned security groups must belong to the same virtual private cloud (VPC).

  • If you specify multiple security groups, the security groups must be of the same type.

k8s.aliyun.com/eci-sls-enable

"false"

Specifies whether to collect logs for a pod. If you do not want to collect logs for a specific pod when you use Simple Log Service CRDs (custom resource definitions) to collect logs, you can set the annotation to false to disable the log collection feature. This prevents waste of resources when the system automatically creates Logtail.

k8s.aliyun.com/eci-spot-strategy

SpotAsPriceGo

The bidding policy for preemptible instances. You can configure this annotation based on your business requirements.

  • SpotWithPriceLimit: The instances are created as preemptible instances that have a maximum hourly price. In this case, you must also configure the Kubernetes. aliyun.com/eci-spot-price-limit annotation.

  • SpotAsPriceGo: The instances are created as preemptible instances for which the market price at the time of purchase is automatically used as the bid price.

k8s.aliyun.com/eci-spot-price-limit

"0.5"

The maximum hourly price for preemptible instances. This value can be accurate to three decimal places. If

k8s.aliyun.com/eci-spot-strategy

is set to

SpotWithPriceLimit

this annotation takes effect.

k8s.aliyun.com/eci-with-eip

"true"

Specifies whether to automatically create and allocate an elastic IP address (EIP) for each elastic container instance.

k8s.aliyun.com/eci-data-cache-bucket

default

The bucket that caches data. You must configure this annotation when you create pods from data caches.

k8s.aliyun.com/eci-data-cache-pl

PL1

The performance level (PL) of the disk that is created from data caches. By default, an enterprise SSD (ESSD) of PL1 is used.

k8s.aliyun.com/eci-data-cache-provisionedIops

"40000"

The provisioned read/write IOPS for the ESSD AutoPL disk. Valid values: 0 to min{50000, 1000 x Capacity - Baseline IOPS}, where Baseline IOPS = min{1800 + 50 x Capacity, 50000}. For more information, see ESSD AutoPL disks.

If you add this annotation, the disk that is created from data caches must be an ESSD AutoPL disk.

k8s.aliyun.com/eci-data-cache-burstingEnabled

"true"

Specifies whether to enable the Burst feature for the ESSD AutoPL disk. For more information, see ESSD AutoPL disks.

If you add this annotation, the disk that is created from data caches must be an ESSD AutoPL disk.

k8s.aliyun.com/eci-custom-tags

"env:test,name:alice"

The tag strings. You can bind up to three tags to each elastic container instance. Separate the tag key and tag value with colons (:). Separate multiple tags with commas (,).

For more information about annotations, see Pod annotations.