Elastic Container Instance-based scheduling is a scheduling policy that Alibaba Cloud provides for elastic resource scheduling. You can add annotations to specify the resources that you want to use when you deploy applications. You can specify that only Elastic Compute Service (ECS) instances or elastic container instances are used, or enable the system to request elastic container instances when ECS resources are insufficient. Elastic Container Instance-based scheduling can meet your resource requirements in different workload scenarios.

Prerequisites

Procedure

Note You can specify the type of elastic resources that you want to use in the annotations parameter in the template.metadata section of the Deployment configuration. The alibabacloud.com/burst-resource annotation can be set to one of the following values:
  • If the value is left empty, only existing ECS resources in the cluster are used. This is the default value.
  • eci: Elastic container instances are used when the ECS resources in the cluster are insufficient.
  • eci_only: Only elastic container instances are used. The ECS resources in the cluster are not used.
  1. Create a nginx-deployment.yaml file and copy the following content to the file:
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: nginx
      labels:
        app: nginx
    spec:
      replicas: 4
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          name: nginx
          annotations:
            alibabacloud.com/burst-resource: eci # Specify the type of resources that you want to use for elastic scheduling. 
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: nginx
            resources:
              limits:
                cpu: 2
              requests:
                cpu: 2
  2. Run the following command to create pods that run on elastic container instances:
    kubectl apply -f nginx-deployment.yaml