We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – Configure Chrony NTP Service on OpenShift 4.x / OKD 4.x

Learn how to – Configure Chrony NTP Service on OpenShift 4.x / OKD 4.x.

This guide will show you simple steps to Configure Chrony time synchronization with a remote server over the Network Time Protocol (NTP) on your OpenShift / OKD 4.x Cluster. OpenShift 4.x is based on CoreOS – RHCOS/FCOS and server modifications is via MachineConfig. So let’s configure Chrony time synchronization on our OpenShift / OKD cluster.

The first step is to create a base64 encoded contents of the chrony.conf file.

cat >chrony.conf<<EOF
server 0.africa.pool.ntp.org iburst
server 1.africa.pool.ntp.org iburst
server 2.africa.pool.ntp.org iburst
driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
logdir /var/log/chrony
keyfile /etc/chrony.keys
EOF

If you have your own NTP servers, edit the file and update server sections.

$ vi chrony.conf

Then encode it as base64

$ base64 -w0 chrony.conf

-- Saving to file ---
base64 -w0 chrony.conf> chrony.64

We can save the base64 value to variable:

chrony_base64=`base64 -w0 chrony.conf`

Create the MachineConfig files – for master / worker nodes.

for i in master worker; do
cat << EOF > ./${i}-chrony-configuration.yml
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
  labels:
    machineconfiguration.openshift.io/role: ${i}
  name: ${i}-chrony-configuration
spec:
  config:
    ignition:
      config: {}
      security:
        tls: {}
      timeouts: {}
      version: 2.2.0
    networkd: {}
    passwd: {}
    storage:
      files:
      - contents:
          source: data:text/plain;charset=utf-8;base64,${chrony_base64}
          verification: {}
        filesystem: root
        mode: 420
        path: /etc/chrony.conf
  osImageURL: ""
EOF
done

Apply configuration files.

oc apply -f ./master-chrony-configuration.yml
oc apply -f ./worker-chrony-configuration.yml

The MachineConfig operator will apply Chrony configurations on all master and worker nodes then reboot them.

Wait for them to come up the confirm the settings.

$ oc adm debug node/<node-name>
  chroot /host

sh-4.4# cat /etc/chrony.conf 
server 0.africa.pool.ntp.org iburst
server 1.africa.pool.ntp.org iburst
server 2.africa.pool.ntp.org iburst
driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
logdir /var/log/chrony
keyfile /etc/chrony.keys

The Chrony is now configured on OpenShift Cluster.

To set correct timezone you can ssh to the node and use timedatectl command:

$ sudo timedatectl set-timezone Africa/Nairobi
$ date
Sat Oct 31 19:57:23 EAT 2020

The output of the timedatectl command:

$ timedatectl 
               Local time: Sat 2020-10-31 20:02:12 EAT
           Universal time: Sat 2020-10-31 17:02:12 UTC
                 RTC time: Sat 2020-10-31 17:02:13
                Time zone: Africa/Nairobi (EAT, +0300)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

OpenShift Courses:

Practical OpenShift for Developers – New Course 2021

Ultimate Openshift (2021) Bootcamp by School of Devops

Check related guides available on our blog.

Run Ceph toolbox for Rook on Kubernetes / OpenShift

Add Harbor Image Registry Pull Secret to Kubernetes / OpenShift

How To Set Static IP Address on RHCOS / FCOS Machine

How To Allow Insecure Registries in OpenShift / OKD 4.x Cluster

Cart

Your Cart is Empty

Back To Shop