All Products
Search
Document Center

Elastic Container Instance:Configure the NTP service

Last Updated:Apr 01, 2026

In time-sensitive applications, clock drift in container pods can cause log timestamps to fall out of order—making incident correlation unreliable—and can lead to data inconsistencies in distributed systems. To prevent these issues, add the k8s.aliyun.com/eci-ntp-server annotation to your Elastic Container Instance (ECI) pod to point containers at a specific NTP server.

Prerequisites

Before you begin, ensure you have:

  • Permission to create Deployments and pods

  • The IP address of an accessible NTP server

How it works

When ECI creates a pod, it reads the k8s.aliyun.com/eci-ntp-server annotation and configures all containers in the pod to synchronize their clocks with the specified NTP server.

ECI annotations are applied only at pod creation. Adding or modifying annotations on a running pod has no effect.

For Deployments, add the annotation in spec.template.metadata.annotations, not in the top-level metadata.annotations. ECI reads annotations from the pod template, not from the Deployment object itself.

Configure NTP for a pod

  1. Create a YAML file named set-ntp.yaml with the following content. Replace 100.100.XX.XX with the IP address of your NTP server.

    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  # IP address of the NTP server
        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 configuration.

    kubectl create -f set-ntp.yaml

Verify NTP configuration

  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 the time synchronization source.

    If chrony is not installed, run yum -y install chrony first.
    chronyc sources

    A line starting with ^* indicates the currently selected source. Confirm that your NTP server IP appears on that line.

    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