Red Hat OpenShift 4 DNS & NTP & PTP 網路套餐
最近雖然受到 COVID-19 影響導致有些國外專案進度有點落後,但就 OpenShift 4 功能本身不知道為啥成長幅度變的蠻快的…有時候想跟也很難跟上,只能透過影片來了解,然後 Red Hat 本家不知道哪根筋不對了,跑去 Twitch (!!??) 開了一個頻道 RedHatOpenShift Twitch,三不五時就開直播上演下圖的狀況,相當有事
走馬看花第 8 天
CoreDNS 做 DNS Forwarder
CoreDNS: DNS and Service Discovery
其實 OpenShift 內建有 DNS 服務,主要目的是要來解析 Service IP <-> DNS,所採用的技術是使用 CoreDNS
。關於 CoreDNS ,主要是提供雲原生的 DNS 服務和服務發現的解決方案,有興趣想參考效能比較的話,可以看 Scaling CoreDNS in Kubernetes Clusters,目前已於 2019/01 時從 CNCF 專案海中畢業。
如果你仔細觀察 CoreDNS 在 OpenShift 上的運作狀況可以發現他是從 openshift-dns-operator
部署,並於每一個節點採用 DaemonSet
的形式運行 CoreDNS
1 | # Operator Information |
倘若你想要透過 VPN 去連線至其他雲裡面的服務,那這樣會有需要特別多加幾條 DNS Forwarder 的能力在集群裡面,遵照 DNS Operator in OpenShift Container Platform
1 | # Default Setting |
時間設定 Chrony
打從 RHEL 7 之後,Red Hat 官方因為安全及效能上的考量,建議從 ntpd
轉換成使用 chronyd
,實際上也是蠻推薦多用 chronyd 當作主要的 NTP Server/Client,就連 OpenShift 預載的 CoreOS 內部也是以 Chronyd 為校時基準,參考 NTP configuration - OpenShift Tips,以下是校時的操作
- 先檢查預設的狀態,隨便挑一台用
oc debug node/<node name>
進去觀察時間
1 | $ oc debug node/ip-10-0-129-186.ap-southeast-1.compute.internal |
準備
chrony.conf
,然後進行 Base64 編碼1
2
3
4
5
6
7
8
9
10
11
12
13$ cat << EOF >> chrony.conf
pool 0.tw.pool.ntp.org iburst
pool 3.tw.pool.ntp.org iburst
driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
keyfile /etc/chrony.keys
leapsectz right/UTC
logdir /var/log/chrony
EOF
$ cat chrony.conf | python3 -m base64 | xargs echo -n
cG9vbCAwLnR3LnBvb2wubnRwLm9yZyBpYnVyc3QKcG9vbCAzLnR3LnBvb2wubnRwLm9yZyBpYnVyc3QKZHJpZnRmaWxlIC92YXIvbGliL2Nocm9ueS9kcmlmdAptYWtlc3RlcCAxLjAgMwpydGNzeW5jCmtleWZpbGUgL2V0Yy9jaHJvbnkua2V5cwpsZWFwc2VjdHogcmlnaHQvVVRDCmxvZ2RpciAvdmFyL2xvZy9jaHJvbnkK準備 2 個聲明檔,如果你在
machine config pool
還有多新增 infra 的話,也要特別寫一個,原則上就是一個角色要有一個檔案就是了1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47$ cat << EOF > 98-worker-chrony.yaml
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
labels:
machineconfiguration.openshift.io/role: worker
name: 98-worker-chrony-configuration
spec:
config:
ignition:
version: 2.2.0
storage:
files:
- contents:
source: data:text/plain;charset=utf-8;base64,cG9vbCAwLnR3LnBvb2wubnRwLm9yZyBpYnVyc3QKcG9vbCAzLnR3LnBvb2wubnRwLm9yZyBpYnVyc3QKZHJpZnRmaWxlIC92YXIvbGliL2Nocm9ueS9kcmlmdAptYWtlc3RlcCAxLjAgMwpydGNzeW5jCmtleWZpbGUgL2V0Yy9jaHJvbnkua2V5cwpsZWFwc2VjdHogcmlnaHQvVVRDCmxvZ2RpciAvdmFyL2xvZy9jaHJvbnkK
verification: {}
filesystem: root
mode: 420
path: /etc/chrony.conf
EOF
$ cat << EOF > 98-master-chrony.yaml
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
labels:
machineconfiguration.openshift.io/role: master
name: 98-master-chrony-configuration
spec:
config:
ignition:
version: 2.2.0
storage:
files:
- contents:
source: data:text/plain;charset=utf-8;base64,cG9vbCAwLnR3LnBvb2wubnRwLm9yZyBpYnVyc3QKcG9vbCAzLnR3LnBvb2wubnRwLm9yZyBpYnVyc3QKZHJpZnRmaWxlIC92YXIvbGliL2Nocm9ueS9kcmlmdAptYWtlc3RlcCAxLjAgMwpydGNzeW5jCmtleWZpbGUgL2V0Yy9jaHJvbnkua2V5cwpsZWFwc2VjdHogcmlnaHQvVVRDCmxvZ2RpciAvdmFyL2xvZy9jaHJvbnkK
verification: {}
filesystem: root
mode: 420
path: /etc/chrony.conf
EOF
$ oc apply -f 98-master-chrony.yaml
machineconfig.machineconfiguration.openshift.io/98-masters-chrony-configuration created
$ oc apply -f 98-worker-chrony.yaml
machineconfig.machineconfiguration.openshift.io/98-workers-chrony-configuration created
精確時間協定 PTP
想不到吧! OpenShift 4 有內建支援 IEEE 1588 (Precision Time Protocol, PTP) 協定,來支援硬體級別的精確時間同步,當然要使用這個技術需要仰賴硬體設備上的支援,包含像是網卡以及交換機,OpenShift 4 是將 Linux PTP 透過 PTP Operator 安裝於所有節點之上,透過內建自動能力查詢機制來協助將具備 PTP 能力之網卡設定其相關參數。其實主要這個功能是為了 O-RAN W6 裡面有定義條目 5.5.1 Cloud Platform Time Synchronization Architecture
而做的,裡面描述如下
The Time Sync deployment architecture which is described below relies on usage of Precision Time Protocol (PTP) IEEE 1588-2008 (a.k.a. IEEE 1588 Version 2) to synchronize clocks throughout the Edge Cloud site.
其實安裝相當簡單,主要是透過 Operator Framework 從頭打到底,如果有興趣想看過程的可以參考該 GitHub - pichuang/redhat-ptp-demo
1 | $ oc get all |
哦對了,我身上沒有支援 PTP 的網卡,所以看不出來效果,帶有錢的大大找我去研究相關使用方式 XD
Appendix
Environment Information
- OpenShift 4.3.27
- Kubernetes Version: v1.16.2+d6d3cff