OCP4 Tips P.03/Change Node NTP Configuration and Time Zone
Remon Ibrahim
Linux/Openshift Administrator at MDI | Former DevOps AutomationEngineer at OBS| Former Cloud and System Administrator at Vodafone Egypt | RHCA? | CKS? | CKA? | RHCE?| RHCSA? | VCP-DCV?|VMware VCA?
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