RHOCP) Machine Config를 이용한 Chrony 설정
INTRO
이전의 글에서 Machine Config Operator에 대해 알아보았고 이번에는 특정 MCP에 Machine Config를 연결하여 node들에 NTP를 설정하는 방법을 소개드리려고 합니다.
RHOCP) Machine Config Operator (MCO)
INTRO RHOCP를 사용하다 보면 여러 노드에 설정을 반영하고 반영된 설정대로 node들의 형상이 지속적으로 유지되어야 할 경우 Machine Config Pool에 있는 node들 대상으로 Machine Config를 설정하여 반영합니
lilo.tistory.com
Machine Config를 이용한 NTP 구성은 아래의 문서를 참고하였습니다.
Machine configuration tasks | Post-installation configuration | OpenShift Container Platform 4.13
You can use the tasks in this section to create MachineConfig objects that modify files, systemd unit files, and other operating system features running on OpenShift Container Platform nodes. For more ideas on working with machine configs, see content rela
docs.openshift.com
Machine Config를 이용한 Chrony(NTP) 설정
RHCOS 4.13.0은 RHEL 8.X 기반이기 때문에 NTP 서비스를 Chrony를 선택하여 설정할 예정입니다.
Machine Config 작성을 도와주고 추가 검증을 수행하기 위한 Syntax를 제공하는 유틸리티입니다. 아래의 사이트에서 Butane 바이너리를 자신이 사용하는 서버의 아키텍처에 맞게 다운로드 받습니다.
https://mirror.openshift.com/pub/openshift-v4/clients/butane/
# curl -LO https://mirror.openshift.com/pub/openshift-v4/clients/butane/latest/butane-amd64
# mv butane-amd64 /usr/local/bin/butane
Butane에 대한 자세한 내용은 아래의 문서를 참고바랍니다.
Customizing nodes - Installation configuration | Installing | OpenShift Container Platform 4.13
For most common hardware, the Linux kernel includes the device driver modules needed to use that hardware when the computer starts up. For some hardware, however, modules are not available in Linux. Therefore, you must find a way to provide those modules t
docs.openshift.com
Control plane, Compute node 대상으로 chrony.conf의 내용이 포함된 Butane config를 작성합니다.
# cat << EOF > 99-worker-chrony.bu
variant: openshift
version: 4.13.0
metadata:
name: 99-worker-chrony
labels:
machineconfiguration.openshift.io/role: worker
storage:
files:
- path: /etc/chrony.conf
mode: 0644
overwrite: true
contents:
inline: |
pool 192.168.56.1 iburst
driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
logdir /var/log/chrony
EOF
<Control plane node 대상 Chrony 설정>
# cat << EOF > 99-master-chrony.bu
variant: openshift
version: 4.13.0
metadata:
name: 99-master-chrony
labels:
machineconfiguration.openshift.io/role: master
storage:
files:
- path: /etc/chrony.conf
mode: 0644
overwrite: true
contents:
inline: |
pool 192.168.56.1 iburst
driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
logdir /var/log/chrony
EOF
butane 명령어를 이용하여 MachineConfig 파일을 생성합니다.
# butane 99-worker-chrony.bu -o 99-worker-chrony.yaml
# butane 99-master-chrony.bu -o 99-master-chrony.yaml
<Control plane Chrony MachineConfig>
# cat 99-master-chrony.yaml
# Generated by Butane; do not edit
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
labels:
machineconfiguration.openshift.io/role: master
name: 99-master-chrony
spec:
config:
ignition:
version: 3.2.0
storage:
files:
- contents:
compression: ""
source: data:,pool%20192.168.56.1%20iburst%20%0Adriftfile%20%2Fvar%2Flib%2Fchrony%2Fdrift%0Amakestep%201.0%203%0Artcsync%0Alogdir%20%2Fvar%2Flog%2Fchrony%0A
mode: 420
overwrite: true
path: /etc/chrony.conf
<Compute node Chrony MachineConfig>
# cat 99-worker-chrony.yaml
# Generated by Butane; do not edit
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
labels:
machineconfiguration.openshift.io/role: worker
name: 99-worker-chrony
spec:
config:
ignition:
version: 3.2.0
storage:
files:
- contents:
compression: ""
source: data:,pool%20192.168.56.1%20iburst%20%0Adriftfile%20%2Fvar%2Flib%2Fchrony%2Fdrift%0Amakestep%201.0%203%0Artcsync%0Alogdir%20%2Fvar%2Flog%2Fchrony%0A
mode: 420
overwrite: true
path: /etc/chrony.conf
생성된 Machine config를 적용합니다.
# oc apply -f 99-master-chrony.yaml
machineconfig.machineconfiguration.openshift.io/99-master-chrony created
# oc apply -f 99-worker-chrony.yaml
machineconfig.machineconfiguration.openshift.io/99-worker-chrony created
MachineConfig가 MCP에 정상적으로 연결이 되면 UPDATING 상태로 변환됩니다.
MachinceConfig가 연결되고 설정이 적용될 때 node는 병렬로 reboot을 하며 1개의 node가 reboot이 완료되고 설정이 정상적으로 반영이 되었으면 다음 node를 reboot하고 설정을 반영하기 때문에 서비스에 큰 영향은 없습니다.
※ MachineConfig 반영이 완료되기 전까지 node의 상태는 SchedulingDisabled 상태이며 Pod를 스케줄링할 수 없습니다.
# oc get mcp
NAME CONFIG UPDATED UPDATING DEGRADED MACHINECOUNT READYMACHINECOUNT UPDATEDMACHINECOUNT DEGRADEDMACHINECOUNT AGE
master rendered-master-029cd0c4ce8789cbc9657485b0cacbbe False True False 3 0 0 0 29h
worker rendered-worker-d6b4c217fa885971481464502920487c False True False 2 0 0 0 29h
아래와 같이 node의 설정 반영이 완료되면 UPDATEDMACHINECOUNT 숫자가 올라가는 것을 확인할 수 있습니다.
# oc get mcp
NAME CONFIG UPDATED UPDATING DEGRADED MACHINECOUNT READYMACHINECOUNT UPDATEDMACHINECOUNT DEGRADEDMACHINECOUNT AGE
master rendered-master-029cd0c4ce8789cbc9657485b0cacbbe False True False 3 1 1 0 29h
worker rendered-worker-d6b4c217fa885971481464502920487c False True False 2 1 1 0 29h
MachineConfig가 정상적으로 반영되면 UPDATED가 True 상태로 변합니다.
[root@bastion1 ~]# oc get mcp
NAME CONFIG UPDATED UPDATING DEGRADED MACHINECOUNT READYMACHINECOUNT UPDATEDMACHINECOUNT DEGRADEDMACHINECOUNT AGE
master rendered-master-f9b4877b9d99846b2d2e873e43fbb016 True False False 3 3 3 0 30h
worker rendered-worker-0e5614e6ae49575265a64ca93e5d2648 True False False 2 2 2 0 30h
node에 Chrony 설정이 정상적으로 되었는지 확인하기 위해 아래의 명령을 수행합니다.
모든 node의 hostname을 jsonpath로 파싱하여 for문을 이용해서 원하는 정보를 얻습니다.
# for node in $(oc get nodes -o jsonpath='{.items[*].metadata.name}'); do ssh core@$node echo 'Hostname: `hostname`'; chronyc sources ;echo; done
Hostname: master1.ocp4.example.com
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 192.168.56.1 4 6 377 57 +27us[ -619us] +/- 42ms
Hostname: master2.ocp4.example.com
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 192.168.56.1 4 6 377 57 +27us[ -619us] +/- 42ms
Hostname: master3.ocp4.example.com
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 192.168.56.1 4 6 377 57 +27us[ -619us] +/- 42ms
Hostname: worker1.ocp4.example.com
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 192.168.56.1 4 6 377 57 +27us[ -619us] +/- 42ms
Hostname: worker2.ocp4.example.com
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 192.168.56.1 4 6 377 58 +27us[ -619us] +/- 42ms