This topic describes how to use reserve instances to reduce the costs of long-running Elastic Container Instances (ECIs). We recommend that you use reserve instances to reduce the costs of ECIs for running long-term online business applications.

Before you begin

You can only use reserve instances to create ECIs of the specified Elastic Compute Service (ECS) instance type. For more information, see Create an ECI of the specified ECS instance type.

1. Purchase reserved instances as needed. For more information, see Purchase reserved instances.

2. View and manage reserved instances. For more information, see Split a reserved instance.

Note Reserved instances match pay-as-you-go ECIs based on matching rules. For more information, see Matching rules of reserved instances.

Kubernetes mode

You can only use reserve instances to create ECIs of the specified ECS instance type. For more information, see Create an ECI of the specified ECS instance type.

  • Log on to the Container Service console. In this example, choose Applications > Deployments in the left-side navigation pane.

  • In the upper-right corner of the Deployments page, click Create from Template.

  • Add the following annotation in the pod template. In this example, an ECI of the ecs.c5.large type is reserved.

Note that you need to add annotations in the metadata parameter for the pod. Specify ECS instance types as needed. For more information, see Instance families.

 annotations:
    k8s.aliyun.com/eci-instance-type : "ecs.c5.large"  # Replace the ECS instance type as needed in the format of ecs.Instance family.Specification. Example: ecs.c6.3xlarge.

Add the annotation in the YAML file of a deployment

Notice You need to add annotations in the metadata parameter for the pod.
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-instance-type : "ecs.c5.large"  # Replace the ECS instance type 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

View the created pod

You can also view the created ECI in the ECI console.
Note A zonal reserved instance must be in the same zone as the Kubernetes cluster for which you want to create an ECI. Otherwise, the reserved instance cannot be used to create an ECI for the Kubernetes cluster.

API mode

You can only use reserve instances to create ECIs of the specified ECS instance type. For more information, see Create an ECI of the specified ECS instance type.

You need to set the InstanceType parameter in the request for calling the CreateContainerGroup operation. For more information, see CreateContainerGroup.

Request parameter

Parameter Type Required Description
InstanceType String Yes The instance type of the ECI to be created.

View the information about the ECI

Log on to the ECI console. View the information about the target ECI on the Container Group page. In this example, you can view the information about the ECI whose ID is eci-2ze2f3qp626x29u2183b.

View the bills

Go to the Bills page and query the bills of the ECI. In this example, you can query the bills of the ECI whose ID is eci-2ze2f3qp626x29u2183b. No bills are generated.

View the deduction details of a reserved instance

Find the target reserved instance

Log on to the ECS console. In the left-side navigation pane, choose Instances & Images > Reserved Instances. On the page that appears, find the target reserved instance and click View Bill in the Actions column.

View the deduction details of the reserved instance

On the Details tab of the Manage Reserved Instances page, view the deduction details of the reserved instance. In this example, you can view the deduction details in each billing cycle of the ECI.
Note One attribute of a reserved instance is computing power. A unit of computing power can be considered as 1 vCPU. The Deducted Amount column displays the total computing power deducted in the deduction duration in hours.