美文网首页
K8S 修改pod 时区问题

K8S 修改pod 时区问题

作者: 无处安放的躁动 | 来源:发表于2019-11-13 15:17 被阅读0次

    修改时区

    通过环境变量设置时区

    apiVersion: v1
    kind: Pod
    metadata:
      name: james-java
      namespace: james
      labels:
        name: james-java
    spec:
      containers:
      - name: james-java
        image: 192.168.0.252/james/java:v1.0.1
        ports:
        - containerPort: 7102
        env:                                    # 添加
          - name: TZ                       # 添加
            value: Asia/Shanghai      # 添加
    

    制作docker镜像时候添加

    # 拷贝到当前目录
    cp /usr/share/zoneinfo/Asia/Shanghai ./localtime
    vim timezone
    Asia/Shanghai
    # 修改dockerfile
    
    FROM 192.168.0.252/szlaozi/java:8u111
    
    MAINTAINER james.liu <liudongliang@szlaozi.com>
    RUN mkdir  /ENV/Microservice/ -p
    ... ... 
    ADD localtime /etc/localtime          # 添加
    ADD timezone /etc/timezone         # 添加
    EXPOSE 7103
    WORKDIR  /ENV/Microservice/
    ... ...
    

    通过挂载本地文件实现

    apiVersion: v1
    kind: Pod
    metadata:
      name: james-java
      namespace: james
      labels:
        name: james-java
    spec:
      containers:
      - name: james-java
        image: 192.168.0.252/szlaozi/java:v0.0.1
        volumeMounts:
        - name: tz-config
          mountPath: /etc/localtime
        ports:
        - containerPort: 7102
      volumes:
      - name: tz-config
        hostPath:
          path: /etc/localtime
    

    参考

    修改时区

    相关文章

      网友评论

          本文标题:K8S 修改pod 时区问题

          本文链接:https://www.haomeiwen.com/subject/jxnhictx.html