In scenarios where you need to create a large number of Elastic Container Instances (ECIs), ECIs may be out of stock. You can specify multiple zones to improve the success rate of creating ECIs. In addition, you can specify multiple instance types to improve the success rate.
How it works
You can specify multiple instance types through the k8s.aliyun.com/eci-use-specs
annotation of a pod to be created. When the corresponding ECI fails to be created
because instances of one instance type are out of stock, the next instance type is
used to create the ECI. For more information, see Pod annotations supported by ECI. When the system tries to recreate the ECI, the ECI remains in the Pending
state.
pod
level. That is, the setting only affects the creation of a pod.
Kubernetes mode
You can specify multiple instance types based on their priorities through the k8s.aliyun.com/eci-use-specs
annotation of a pod to be created.
apiVersion: apps/v1beta2 # For versions earlier than 1.8.0, use apps/v1beta1.
kind: Deployment
metadata:
name: nginx-deployment-basic
labels:
app: nginx
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
annotations:
k8s.aliyun.com/eci-use-specs : "ecs.c5.large,ecs.c6.large,ecs.sn1ne.large,ecs.g5.large" # Replace the Elastic Compute Service (ECS) instance types as needed.
spec:
# nodeSelector:
# env: test-team
containers:
- name: nginx
image: nginx:1.7.9 # Replace it with your image name, in the format of <image_name:tags>.
ports:
- containerPort: 80
API mode
When you call the CreateContainerGroup operation to create an ECI, you can specify multiple zones through the VSwitchId parameter and specify multiple instance types through the InstanceType parameter. For more information about other parameters, see CreateContainerGroup.
The following table describes the parameters that you need to set in the request.
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
VSwitchId | String | Yes | vsw-*** | The ID of the VSwitch used to create the ECI. You can specify up to 10 VSwitches IDs separated with commas (,). Example: vsw-***,vsw-***. |
InstanceType | String | No | ecs.c5.xlarge | The instance type of the ECI to be created. You can specify up to five instance types separated with commas (,). Example: ecs.c5.xlarge,ecs.g5.xlarge. |
Specify multiple zones for creating an ECI
You can specify multiple zones and multiple instance types at the same time. This greatly improves the success rate of creating ECIs. For more information, see Specify multiple zones for creating an ECI.