• OpenShift4 节点TimeZone修改


    # TimeZone修改

    ## 1. 新建一个修改TimeZone的脚本

    **cat change_timezone_to_shanghai.sh**

    ```

    #!/bin/sh

    set -eux

    MD5_DST=$(md5sum /usr/share/zoneinfo/Asia/Shanghai | awk '{print $1}')

    MD5_SRC=$(md5sum /etc/localtime | awk '{print $1}')

    if [[ "${MD5_DST}" != "${MD5_SRC}" ]]; then

    rm -rf /etc/localtime

    cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

    fi

    ```

    ## 2.将该脚本编码为base64格式

    **cat change_timezone_to_shanghai.sh | base64 -w0**

    `IyEvYmluL3NoCnNldCAtZXV4CgpNRDVfRFNUPSQobWQ1c3VtIC91c3Ivc2hhcmUvem9uZWluZm8vQXNpYS9TaGFuZ2hhaSB8IGF3ayAne3ByaW50ICQxfScpCk1ENV9TUkM9JChtZDVzdW0gL2V0Yy9sb2NhbHRpbWUgfCBhd2sgJ3twcmludCAkMX0nKQoKaWYgW1sgIiR7TUQ1X0RTVH0iICE9ICIke01ENV9TUkN9IiBdXTsgdGhlbgogICAgcm0gLXJmIC9ldGMvbG9jYWx0aW1lCiAgICBjcCAvdXNyL3NoYXJlL3pvbmVpbmZvL0FzaWEvU2hhbmdoYWkgL2V0Yy9sb2NhbHRpbWUKZmkK`

    ## 3.在`10-worker.yaml`中添加timezone-99bill.service服务和/usr/local/sbin/timezone.sh文件

    **cat 10-worker.yaml**

    apiVersion: machineconfiguration.openshift.io/v1
    kind: MachineConfig
    metadata:
      annotations:
      labels:
        machineconfiguration.openshift.io/role: worker
      name: 10-worker
    spec:
      config:
        ignition:
          version: 2.2.0
        storage:
          files:
          - contents:
              source: data:text/plain;charset=utf-8;base64,IyEvYmluL3NoCnNldCAtZXV4CgpNRDVfRFNUPSQobWQ1c3VtIC91c3Ivc2hhcmUvem9uZWluZm8vQXNpYS9TaGFuZ2hhaSB8IGF3ayAne3ByaW50ICQxfScpCk1ENV9TUkM9JChtZDVzdW0gL2V0Yy9sb2NhbHRpbWUgfCBhd2sgJ3twcmludCAkMX0nKQoKaWYgW1sgIiR7TUQ1X0RTVH0iICE9ICIke01ENV9TUkN9IiBdXTsgdGhlbgogICAgcm0gLXJmIC9ldGMvbG9jYWx0aW1lCiAgICBjcCAvdXNyL3NoYXJlL3pvbmVpbmZvL0FzaWEvU2hhbmdoYWkgL2V0Yy9sb2NhbHRpbWUKZmkK
            filesystem: root
            mode: 493
            path: /usr/local/sbin/timezone.sh
        systemd:
          units:
          - contents: |
              [Unit]
              Description=Modify Timezone to Asia/Shanghai
              After=NetworkManager.service
    
              [Service]
              Type=oneshot
              RemainAfterExit=yes
              User=root
    
              # SystemD prevents direct execution of the script in /usr/local/sbin,
              # so it is sourced. See the script for functionality.
              ExecStart=/usr/local/sbin/timezone.sh
    
              # Wait up to 5min for the node to get a real hostname.
              TimeoutSec=300
    
              [Install]
              WantedBy=multi-user.target
            enabled: true
            name: timezone.service
    

      

    ## 4. 部署该MC

    ```

    oc apply -f 10-worker.yaml

    ```

    这样,worker节点的时区就会改成Shanghai,如果要修改master节点的时区,可以按照上述方法新增master节点的相关mc对象即可。

  • 相关阅读:
    springboot部署到tomcat
    新建 SecondPresenter 实现类
    BaseFragment 基类
    BaseActivity 基类
    ProxyImpl 类
    BaseFragment 基类代码
    对于大量数据存储入库问题的解决办法
    MainActivity.java 文件
    activity_main.xml 添加自己画的view 组件
    MyView.java 自己画的view
  • 原文地址:https://www.cnblogs.com/yehaifeng/p/15935173.html
Copyright © 2020-2023  润新知