How to configure NTP and Timezone on OpenShift?

##########################################
#### Openshift 4.8 and higher                             ####
##########################################

##########################################
#### Butane Installation                                        ####
##########################################

curl https://mirror.openshift.com/pub/openshift-v4/clients/butane/latest/butane –output butane
chmod +x butane
mv butane /usr/bin

##########################################
#### OpenShift NTP Configuration                      ####
#### NTP Servers: 10.1.1.11, 10.1.1.12              ####
##########################################

cat << EOF > 99-worker-custom.bu
variant: openshift
version: 4.8.0
metadata:
  name: 99-worker-custom
  labels:
    machineconfiguration.openshift.io/role: worker
openshift:
  kernel_arguments:
    – loglevel=7
storage:
  files:
    – path: /etc/chrony.conf
      mode: 0644
      overwrite: true
      contents:
        inline: |
          server 10.1.1.11
          server 10.1.1.12
          driftfile /var/lib/chrony/drift
          makestep 1.0 3
          rtcsync
          logdir /var/log/chrony
EOF

butane 99-worker-custom.bu -o ./99-worker-custom.yaml

oc create -f 99-worker-custom.yaml

cat << EOF > 99-master-custom.bu
variant: openshift
version: 4.8.0
metadata:
  name: 99-master-custom
  labels:
    machineconfiguration.openshift.io/role: master
openshift:
  kernel_arguments:
    – loglevel=7
storage:
  files:
    – path: /etc/chrony.conf
      mode: 0644
      overwrite: true
      contents:
        inline: |
          server 10.1.1.11
          server 10.1.1.12
          driftfile /var/lib/chrony/drift
          makestep 1.0 3
          rtcsync
          logdir /var/log/chrony
EOF

butane 99-master-custom.bu -o ./99-master-custom.yaml
oc create -f 99-master-custom.yaml


#######################################
#### OpenShift Timezone Configuration     ####
#### Create one shot services                       ####

#######################################

cat << EOF > 99-master-timezone.bu
variant: openshift
version: 4.8.0
metadata:
  labels:
    machineconfiguration.openshift.io/role: master
  name: master-custom-timezone-configuration
systemd:
  units:
  – contents: |
      [Unit]
      Description=set timezone
      After=network-online.target
      [Service]
      Type=oneshot
      ExecStart=timedatectl set-timezone Europe/Istanbul
      [Install]
      WantedBy=multi-user.target
    enabled: true
    name: custom-timezone.service
EOF

butane 99-master-timezone.bu -o ./99-master-timezone.yaml
oc create -f 99-master-timezone.yaml

cat << EOF > 99-worker-timezone.bu
variant: openshift
version: 4.8.0
metadata:
  labels:
    machineconfiguration.openshift.io/role: worker
  name: worker-custom-timezone-configuration
systemd:
  units:
  – contents: |
      [Unit]
      Description=set timezone
      After=network-online.target
      [Service]
      Type=oneshot
      ExecStart=timedatectl set-timezone Europe/Istanbul
      [Install]
      WantedBy=multi-user.target
    enabled: true
    name: custom-timezone.service
EOF

butane 99-worker-timezone.bu -o ./99-worker-timezone.yaml
oc create -f 99-worker-timezone.yaml

By:

Posted in:


Leave a comment