If you want the containers in a pod deployed on a virtual node to synchronize time with the Network Time Protocol (NTP) service, you need to configure NTP for the pod.
Procedure
Add the k8s.aliyun.com/eci-ntp-server
annotation to the pod. The annotation specifies the IP address of the NTP server that you want to use.
Create a YAML file to configure the NTP service.
vim set-ntp-pod.yaml
The YAML file contains the following content:
apiVersion: v1 kind: Pod metadata: annotations: k8s.aliyun.com/eci-ntp-server: 10.10.5.1 # The IP address of the NTP server. name: set-custom-ntp spec: nodeName: virtual-kubelet containers: - image: centos:latest command: - sleep - "3600" imagePullPolicy: IfNotPresent name: centos
Use the configurations in the YAML file for the pod.
kubectl apply -f set-ntp-pod.yaml
Verify the configuration results
Log on to the container to check whether the NTP service works as expected.
Query the information about the pod.
kubectl get pod/set-custom-ntp
Expected output:
NAME READY STATUS RESTARTS AGE set-custom-ntp 1/1 Running 0 7m20s
Access the container.
kubectl exec set-custom-ntp -it -- bash
Query the source from which the time of container is synchronized.
chronyc sources
If the IP address of the NTP server is returned, the NTP service works as expected. Expected output:
210 Number of sources = 1 MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^* 10.10.5.1 2 6 377 35 +40us[ +135us] +/- 14ms
References
Specify a time zone for the pod. For more information, see Specify time zones for pods.
For more information about ack-virtual-node, see ack-virtual-node.