When an Elastic Container Instance (ECI) provides long-term services, you can use reserved instances to deduct the costs. This topic describes how to use reserved instances.

Prerequisites

  1. Purchase reserved instances based on your actual needs. For more information, see Purchase reserved instances.
  2. You can view and manage your reserved instances. For more information, see Split a reserved instance.
Note Reserved instances are automatically applied to pay-as-you-go ECIs based on matching rules. For more information about matching rules, see Matching rules of Reserved Instances.

Procedure

A reserved instance is only applicable when you create an ECI based on a specified ECS instance type. For more information, see Specify ECS instance types to create an ECI.

Add the following annotations to the templte of a pod. In this example, the reserved instance is used to buy an ecs.c5.large instance:

annotations:
    k8s.aliyun.com/eci-instance-type : "ecs.c5.large"# Replace the value with the actual ECS instance type in the following format: ecs. instance family. instance specification, for example, ecs.c6.3xlarge
Note annotations must be added to the spec field of the pod. Enter the ECS specification as needed. For more information about supported ECS types, see Instance families.

Deployment example

annotations must be added to the metadata field of the pod.

Note The zone of the reserved instance must be the same as that of your Kubernetes cluster. Otherwise, the reserved instance cannot match the ECI created in the Serverless Kubernetes cluster.
apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: nginx
  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 value with the ECS instance type as needed.
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80

View the billing details of a reserved instance

View the bill of a reserved instance

  1. Log on to the ECS console.
  2. In the left-side navigation pane, choose Instances & Images > Reserved Instances.
  3. In the top navigation bar, select a region.
  4. Find the target reserved instance and click View Bill in the Actions column.
  5. On the Manage Reserved Instances page, click Details.
    You can view the usage details of the reserved instances. These details show the ECS instances or ECIs that are offset by the reserved instances during every billing hour.
    Note One computing unit equals one vCPU. The deductible duration (hours) equals the number of computing units multiplied by the number of hours.