All Products
Search
Document Center

Elastic Container Instance:Configure the NTP service

Last Updated:Apr 01, 2026

To control which NTP server your ECI pod synchronizes with — for example, to meet compliance requirements, improve timestamp accuracy in distributed logs, or synchronize with an internal time source — add the k8s.aliyun.com/eci-ntp-server annotation when creating the pod.

Prerequisites

Before you begin, ensure that you have:

  • A Kubernetes cluster with the ECI add-on installed

  • kubectl configured to connect to your cluster

  • The IP address of your NTP server

Usage notes

  • Add annotations to the pod metadata section of your configuration file. For a Deployment, this is spec.template.metadata.annotations.

  • Annotations take effect only when the pod is created. Adding or modifying the annotation on an existing pod has no effect.

Configure NTP for a pod

  1. Create a Deployment manifest. Set the k8s.aliyun.com/eci-ntp-server annotation to your NTP server's IP address.

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: test-ntp
      labels:
        app: test
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          name: test-ntp
          labels:
            app: nginx
            alibabacloud.com/eci: "true"
          annotations:
            k8s.aliyun.com/eci-ntp-server: 100.100.XX.XX  # Replace with your NTP server IP address.
        spec:
          containers:
          - name: nginx
            image: registry.cn-shanghai.aliyuncs.com/eci_open/centos:7
            ports:
            - containerPort: 80
            command: ["/bin/sh","-c","sleep 3600"]
  2. Apply the manifest.

    kubectl create -f set-ntp.yaml

Verify NTP synchronization

  1. Get the pod name.

    kubectl get pod

    Expected output:

    NAME                        READY   STATUS    RESTARTS   AGE
    test-ntp-599d5ff9f5-9kb56   1/1     Running   0          3m59s
  2. Open a shell in the container.

    kubectl exec -it test-ntp-599d5ff9f5-9kb56 -- bash
  3. Check whether chrony is installed. If it is not, install it before proceeding.

    yum -y install chrony
  4. Check the NTP time source.

    chronyc sources

    Expected output:

    210 Number of sources = 1
    MS Name/IP address         Stratum Poll Reach LastRx Last sample
    ===============================================================================
    ^* 100.100.XX.XX                    2   6   377     35   +40us[ +135us] +/-   14ms

    The ^* in the first column marks the currently active time source. If your NTP server IP address appears on this line, time synchronization is working.