OCP4 Tips P.03/Change Node NTP Configuration and Time Zone

OCP4 Tips P.03/Change Node NTP Configuration and Time Zone

Hello Everyone, In this article we will talk on how to change node NTP configuration and time zone

things you need to know

1- IPI installation has no NTP configuration during installation

2- so you must make sure that your DHCP config to serve NTP to clients

3- if DHCP not sending list of NTP servers to sync from , then your nodes will has only the list of public NTP servers to sync time from and that may be blocked by your firewall so if you will depend on those public NTP make sure to open the required ports for them

4- during installation bootstrap nodes and all nodes must be time synced or installation may fail

Our goal for today is to change the NTP servers to sync from and the time zone after installation completed and you have up and running Openshift cluster

1- we will create our Chrony config file, here is a sample chrony.conf file

? cat chrony.conf

    server <your NTP server IP> iburst
? ? driftfile /var/lib/chrony/drift
? ? makestep 1.0 3
? ? rtcsync
? ? logdir /var/log/chrony
        

2- encode chrony.conf file to base64

cat chrony.conf | base64

ICAgIHNlcnZlciA8eW91ciBOVFAgc2VydmVyIElQPiBpYnVyc3QKICAgIGRyaWZ0ZmlsZSAvdmFy
L2xpYi9jaHJvbnkvZHJpZnQKICAgIG1ha2VzdGVwIDEuMCAzCiAgICBydGNzeW5jCiAgICBsb2dk
aXIgL3Zhci9sb2cvY2hyb255Cg==


        

3- we will create 2 machineconfig (MC) files which will hold the chrony.conf file and apply it on worker on masters , you will need to create machineconfig for each MCP you have, in my case I only has 2 MCP worker, master

here is the worker MC

cat 99-worker-chrony

apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
? annotations:
? labels:
? ? machineconfiguration.openshift.io/role: worker
? name: 99-worker-chrony
spec:
? config:
? ? ignition:
? ? ? config: {}
? ? ? security:
? ? ? ? tls: {}
? ? ? timeouts: {}
? ? ? version: 3.1.0
? ? networkd: {}
? ? passwd: {}
? ? storage:
? ? ? files:
? ? ? - contents:
? ? ? ? ? source: data:text/plain;charset=utf-8;base64,ICAgIHNlcnZlciA8eW91ciBOVFAgc2VydmVyIElQPiBpYnVyc3QKICAgIGRyaWZ0ZmlsZSAvdmFyL2xpYi9jaHJvbnkvZHJpZnQKICAgIG1ha2VzdGVwIDEuMCAzCiAgICBydGNzeW5jCiAgICBsb2dk
aXIgL3Zhci9sb2cvY2hyb255Cg==
? ? ? ? mode: 420
? ? ? ? overwrite: true
? ? ? ? path: /etc/chrony.conf
? osImageURL: ""

        

and here is the master MC

cat 99-master-chrony

apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
? annotations:
? labels:
? ? machineconfiguration.openshift.io/role: master
? name: 99-master-chrony
spec:
? config:
? ? ignition:
? ? ? config: {}
? ? ? security:
? ? ? ? tls: {}
? ? ? timeouts: {}
? ? ? version: 3.1.0
? ? networkd: {}
? ? passwd: {}
? ? storage:
? ? ? files:
? ? ? - contents:
? ? ? ? ? source: data:text/plain;charset=utf-8;base64,ICAgIHNlcnZlciA8eW91ciBOVFAgc2VydmVyIElQPiBpYnVyc3QKICAgIGRyaWZ0ZmlsZSAvdmFyL2xpYi9jaHJvbnkvZHJpZnQKICAgIG1ha2VzdGVwIDEuMCAzCiAgICBydGNzeW5jCiAgICBsb2dk
aXIgL3Zhci9sb2cvY2hyb255Cg==
? ? ? ? mode: 420
? ? ? ? overwrite: true
? ? ? ? path: /etc/chrony.conf
? osImageURL: ""        

4- apply the 2 MC

oc apply -f 99-master-chrony
oc apply -f 99-master-chrony        

5- wait until MCP apply both machineconfigs on all nodes

oc get mcp        

so until now we managed to change ntp/chrony configuration on the nodes, but what about the time zone how to change it

1- to change the time zone we will need to create 2 new machine configs that run system unit that change the time zone

here is for worker

cat worker-custom-timezone

apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
? labels:
? ? machineconfiguration.openshift.io/role: worker
? name: worker-custom-timezone-configuration
spec:
? config:
? ? ignition:
? ? ? config: {}
? ? ? security:
? ? ? ? tls: {}
? ? ? timeouts: {}
? ? ? version: 2.2.0
? ? networkd: {}
? ? passwd: {}
? ? storage: {}
? ? systemd:
? ? ? units:
? ? ? - contents: |
? ? ? ? ? [Unit]
? ? ? ? ? Description=set timezone
? ? ? ? ? After=network-online.target


? ? ? ? ? [Service]
? ? ? ? ? Type=oneshot
? ? ? ? ? ExecStart=timedatectl set-timezone Africa/Cairo


? ? ? ? ? [Install]
? ? ? ? ? WantedBy=multi-user.target
? ? ? ? enabled: true
? ? ? ? name: custom-timezone.service
? osImageURL: ""

        

and here is for master

cat master-custom-timezone

apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
? labels:
? ? machineconfiguration.openshift.io/role: master
? name: master-custom-timezone-configuration
spec:
? config:
? ? ignition:
? ? ? config: {}
? ? ? security:
? ? ? ? tls: {}
? ? ? timeouts: {}
? ? ? version: 2.2.0
? ? networkd: {}
? ? passwd: {}
? ? storage: {}
? ? systemd:
? ? ? units:
? ? ? - contents: |
? ? ? ? ? [Unit]
? ? ? ? ? Description=set timezone
? ? ? ? ? After=network-online.target


? ? ? ? ? [Service]
? ? ? ? ? Type=oneshot
? ? ? ? ? ExecStart=timedatectl set-timezone Africa/Cairo


? ? ? ? ? [Install]
? ? ? ? ? WantedBy=multi-user.target
? ? ? ? enabled: true
? ? ? ? name: custom-timezone.service
? osImageURL: ""        

2- apply the 2 machine configs

oc apply -f master-custom-timezone
oc apply -f worker-custom-timezone        

3- wait until again mcp apply them on all nodes

oc get mcp        

this will be the end for today , thanks for keep reading , hope that add something new to you

and here are the docs related to that topic

要查看或添加评论,请登录

Remon Ibrahim的更多文章

  • Ansible & at: Your Secret Weapon for Automated Sudo Revocation

    Ansible & at: Your Secret Weapon for Automated Sudo Revocation

    Hello Everyone, Below is a simple practical Ansible playbook for automating the granting and revocation of Sudo access.…

    6 条评论
  • OCP4 Tips P.10/Upgrade OpenShift Offline & Go Disconnected

    OCP4 Tips P.10/Upgrade OpenShift Offline & Go Disconnected

    Happy New Year to all! May the year ahead be filled with joy, success, and prosperity. In today's article, we will…

    17 条评论
  • OCP4 Tips P.09/machine set deletion policy

    OCP4 Tips P.09/machine set deletion policy

    Hello All, Hope all of you are doing well, in today's article we will talk about machine set what is it why we need…

    2 条评论
  • Ansible Automation without Playbooks

    Ansible Automation without Playbooks

    Hello Everyone, In today's articles we are going to talk about ansible, most of you know ansible as it is a…

    3 条评论
  • OCP4 Tips P.08/Scheduler vs node Requests vs node Utilization

    OCP4 Tips P.08/Scheduler vs node Requests vs node Utilization

    Hi All, Did you ever ask yourself about the following questions: what will happen if we run all pods without defining…

    4 条评论
  • OCP4 Tips P.07/Install OpenShift on VMware Using IPI Method and static IPs.

    OCP4 Tips P.07/Install OpenShift on VMware Using IPI Method and static IPs.

    Hello All, Today we are going to talk about new feature on OpenShift 4.14 enable us to install OpenShift on VMware…

    1 条评论
  • OCP4 Tips P.06/OpenShift Advanced Cluster Management (ACM)

    OCP4 Tips P.06/OpenShift Advanced Cluster Management (ACM)

    Hello All, we have talked before about OpenShift day 2 operations, and we saw that are many tasks you need to do after…

    1 条评论
  • OCP4 Tips P.05/OpenShift MachineSets with VMware Environment

    OCP4 Tips P.05/OpenShift MachineSets with VMware Environment

    Hello Everyone, In this week, our article will be about Openshift MachineSets , what they are, where are they used in…

  • OCP4 Tips P.04/Day 2 Operations

    OCP4 Tips P.04/Day 2 Operations

    Hello Everyone, today will answer one of the important questions, what should we do after day 1 implementation/install…

    5 条评论
  • VSphere Automation with PowerCLI part 03

    VSphere Automation with PowerCLI part 03

    Hello Everyone This is our third article in Vsphere Automation with PowerCLI ,if you still didn't read the others you…

    1 条评论

社区洞察

其他会员也浏览了