云容器引擎 CCE-容器与节点时区同步:场景三:工作负载与节点时区同步

时间:2024-04-03 08:02:33

场景三:工作负载与节点时区同步

  • 方法一:制作容器镜像时,将时区设置为CST。
  • 方法二:若不希望修改容器,可在CCE控制台创建工作负载时,将本机的“/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
support.huaweicloud.com/bestpractice-cce/cce_bestpractice_00229.html