All Products
Search
Document Center

Elastic Container Instance:Bind custom tags to a pod

Last Updated:Aug 25, 2026

Tags are key-value pairs that identify elastic container instances. Use tags to group, search, or run batch operations on instances. Bind custom tags to a pod to manage it by tag — for example, to analyze costs.

Background information

A tag is a key-value pair that functions similarly to a Kubernetes label. Alibaba Cloud tags identify cloud resources and let you manage them by category. By default, elastic container instances created by Container Service for Kubernetes (ACK) have the following tags:

  • ManagedBy: The cluster type.

  • ClusterId: The cluster ID.

  • NameSpace: The namespace of the cluster.

  • OwnerReferenceKind: The workload type created in the cluster, such as Deployment or Job.

  • OwnerReferenceName: The workload name created in the cluster, such as a Deployment name or a Job name.

  • PodName: The pod name.

Configurations

Add the k8s.aliyun.com/eci-custom-tags annotation to a pod to bind custom tags. A pod can have up to three tags. Separate a tag key and a tag value with a colon (:). Separate multiple tags with commas (,).

Important
  • Annotations must be added to the metadata in the configuration file of the pod. For example, when you create a Deployment, you must add annotations in the spec.template.metadata section.

  • Elastic Container Instance-related annotations are only applied when a pod is created. Adding or modifying these annotations on an existing pod will have no effect.

Sample configurations:

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-custom-tags: "env:test,name:alice"   # Apply custom tags
    spec:
      containers:
      - name: nginx
        image: registry.cn-shanghai.aliyuncs.com/eci_open/nginx:1.14.2
        ports:
        - containerPort: 80

After you bind tags, run the kubectl describe command to view the pod's details. The custom tags appear as the value of k8s.aliyun.com/eci-custom-tags in the Annotations section.

~$ kubectl get pod
NAME                    READY   STATUS    RESTARTS   AGE
test-555f6995c6-jrmtl   1/1     Running   0          31m
test-555f6995c6-tqjjk   1/1     Running   0          31m
~$ kubectl describe pod test-555f6995c6-jrmtl
Name:         test-555f6995c6-jrmtl
Namespace:    default
Priority:     0
Node:         virtual-kubelet-cn-beijing-k/172.16.xxx.xxx
Start Time:   Tue, 22 Nov 2022 02:49:42 +0000
Labels:       alibabacloud.com/eci=true
              app=nginx
              pod-template-hash=555f6995c6
Annotations:  ProviderCreate: done
              k8s.aliyun.com/cluster-dns:
              k8s.aliyun.com/cluster-domain: cluster.local
              k8s.aliyun.com/eci-client-token: bbb1a0f7-ad20-440c-a95c-00d9c064f4bc
              k8s.aliyun.com/eci-created-by-template: true
              k8s.aliyun.com/eci-custom-tags: env:test,name:alice
              k8s.aliyun.com/eci-drop-apiserver-interactive-caps:
              k8s.aliyun.com/eci-instance-cpu: 2.0

To view the tags bound to a pod, go to the Container Group page of the Elastic Container Instance console.