更新时间:2023-10-27 GMT+08:00

时区同步

创建工作负载时,支持设置容器使用节点相同的时区。您可以在创建工作负载时打开时区同步配置。

时区同步功能依赖容器中挂载的本地磁盘(HostPath),如下所示,开启时区同步后,Pod中会通过HostPath方式,将节点的“/etc/localtime”挂载到容器的“/etc/localtime”,从而使得节点和容器使用相同的时区配置文件。

kind: Deployment
apiVersion: apps/v1
metadata:
  name: test
  namespace: default
spec:
  replicas: 2
  selector:
    matchLabels:
      app: test
  template:
    metadata:
      labels:
        app: test
    spec:
      volumes:
        - name: vol-162979628557461404
          hostPath:
            path: /etc/localtime
            type: ''
      containers:
        - name: container-0
          image: 'nginx:alpine'
          volumeMounts:
            - name: vol-162979628557461404
              readOnly: true
              mountPath: /etc/localtime
          imagePullPolicy: IfNotPresent
      imagePullSecrets:
        - name: default-secret