This topic describes the compute specifications supported by Elastic Container Instance and describes the methods for creating elastic container instance-based pods. You can select a proper method to create an elastic container instance-based pod based on your business requirements. This helps you improve the success rate of pod creation and reduce resource costs while ensuring resource supply for your elastic container instance-based pods.
Examples for specifying the compute specification when creating an elastic container instance-based pod
If you do not need to specify compute categories, Elastic Compute Service (ECS) instance families, generations of ECS instance families, or ARM-based ECS instance types when you create an elastic container instance-based pod, you can add the k8s.aliyun.com/eci-use-specs annotation to the pod metadata.
The annotation must be added to the metadata in the pod configuration file. For example, when you create a Deployment, you must add the annotation to the spec.template.metadata section.
When you specify multiple specifications, you can specify vCPU and memory specifications or ECS instance types. You can also specify both of them.
ImportantAfter the pod is created, you can check the specifications that are actually used by the pod in the
k8s.aliyun.com/eci-instance-specfield in the YAML file of the pod. If the pod uses an ECS instance type, you are charged based on the ECS instance type. If the pod uses vCPU and memory specifications, you are charged based on the number of vCPUs and memory size.You must specify specifications in a priority order. A maximum of five specifications can be specified.
If you want to create GPU-accelerated elastic container instances, elastic container instances that use local disks, or Arm-based elastic container instances, you can only specify corresponding specifications. The specifications that do not support the preceding features cannot be specified.
Example 1: Specify GPU specifications
apiVersion: apps/v1
kind: Deployment
metadata:
name: test
labels:
app: test
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
name: nginx-test
labels:
app: nginx
alibabacloud.com/eci: "true"
annotations:
k8s.aliyun.com/eci-use-specs: "ecs.gn6i-c4g1.xlarge,ecs.gn6i-c8g1.2xlarge" # Specify a maximum of five GPU-accelerated ECS instance types at a time.
spec:
containers:
- name: nginx
image: registry.cn-shanghai.aliyuncs.com/eci_open/nginx:1.14.2
resources:
limits:
nvidia.com/gpu: "1" # The number of GPUs required by the Nginx container. The GPUs are shared.
ports:
- containerPort: 80
- name: busybox
image: registry.cn-shanghai.aliyuncs.com/eci_open/busybox:1.30
command: ["sleep"]
args: ["999999"]
resources:
limits:
nvidia.com/gpu: "1" # The number of GPUs required by the BusyBox container. The GPUs are shared.Example 2: Specify both vCPU/memory specifications and ECS instance types
apiVersion: apps/v1
kind: Deployment
metadata:
name: test
labels:
app: test
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
name: nginx-test
labels:
app: nginx
alibabacloud.com/eci: "true"
annotations:
k8s.aliyun.com/eci-use-specs: 2-4Gi,ecs.c5.large,ecs.c6.large # Sets the specifications that you want to use to create the pod. Replace the value by using the actual specifications.
spec:
containers:
- name: nginx
image: registry.cn-shanghai.aliyuncs.com/eci_open/nginx:1.14.2
ports:
- containerPort: 80Compute specifications supported by Elastic Container Instance
vCPU and memory specifications supported by Elastic Container Instance
ECS instance families supported by Elastic Container Instance
References
Overview of creation methods
You can use different methods to create pods based on your business and usage scenarios. These methods correspond to different billing modes. For more information, see Billing of elastic container instances.
Creation method | Billing basis | Description | References |
Specify the number of vCPUs and memory size | Based on the vCPU and memory specifications | You are charged for pods based on the vCPU and memory specifications that you specify when you create the pods. You can also specify a compute category based on your cost and performance requirements. For vCPU and memory specifications that are not supported, the system adjusts the instance specifications and charges you based on the new specifications. | |
Specify an ECS instance type | Based on the ECS instance type | You are charged for pods based on the ECS instance types that you specify when you create the pods. You can specify an ECS instance type as the underlying support of your Elastic Container Instance pod based on your business requirements. This way, the pod can obtain the specific capabilities of the ECS instance type. For example, if you specify the ecs.gn6i-c4g1.xlarge instance type, the pod can obtain the GPU-accelerated capabilities. | |
Set ECS instance families or instance family generations for filtering while you specify specifications of vCPU and memory | Based on the ECS instance type | The system automatically selects a suitable ECS instance type based on the specifications of vCPU and memory and the filter conditions for ECS instance families or instance family generations that you specify when you create the pod. You are charged based on the actually used ECS instance type. |
Pods support the x86 architecture (default) and ARM architecture. For information about how to create pods of the ARM architecture, see Schedule pods to an ARM-based virtual node.
Optimize usage costs of pods
You can use pay-as-you-go elastic container instances together with preemptible elastic container instances, reserved instances, and savings plans to reduce costs based on your business requirements.
Preemptible elastic container instances can be used for stateless and fault-tolerant workloads. For more information, see Create a preemptible elastic container instance.
For long-term stable workloads, we recommend that you use reserved instances or savings plans to offset the bills of pods. The following methods can be used to offset your bills based on the billing basis of pods:
Pods for which you are charged based on the number of vCPUs and memory size: General-purpose savings plans can be used.
Pods for which you are charged based on the ECS instance types: General-purpose savings plans, ECS compute savings plans, and reserved instances can be used.
You can select an offset method based on your elastic container instances. For more information, see Use reserved instances and Use savings plans.
Respond to insufficient resources
Elastic Container Instance provides cloud resources for containers. When you create a large number of pods, some resources in the specified region and zone may be insufficient. To ensure that the pods can be created, we recommend that you specify multiple pod specifications and multiple vSwitches that are deployed in different zones. For more information, see the following topics: