Skip to content解壓縮檔案,並將 oc、openshift-install 和 kubectl 加至 PATH 環境變數
確認 oc Command 版本
螢幕輸出 :
Client Version: 4.18.13
Kustomize Version: v5.4.2
確認 openshift-install Command 版本
螢幕輸出 :
openshift-install 4.18.13
built from commit 9357b668a760d53a34f7094840d1e9f773127441
release image quay.io/openshift-release-dev/ocp-release@sha256:a93c65b0f9de1d2e29641fbeebc07178733db1cacc7bde178033d7b9183540bc
release architecture amd64
確認 kubectl Command 版本
螢幕輸出 :
clientVersion:
buildDate: "2025-05-06T22:17:45Z"
compiler: gc
gitCommit: 35f7af703663a7459e0bc494e69ed2cc80543d04
gitTreeState: clean
gitVersion: v1.31.1
goVersion: go1.22.12 (Red Hat 1.22.12-2.el9_5) X:strictfipsruntime
major: "1"
minor: "31"
platform: linux/amd64
kustomizeVersion: v5.4.2
Step 2: 安裝 DNS Server
編輯 DNS Server 設定檔 named.conf
要改的地方有兩個部分
- 將
listen-on port 53 和 allow-query 的值, 改成 any
檔案內容 :
options {
listen-on port 53 { any; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
secroots-file "/var/named/data/named.secroots";
recursing-file "/var/named/data/named.recursing";
allow-query { any; };
- 假設我 bastion 這台機器的 Hostname 是
bastion.topgun.kubeantony.com
IP 是 192.168.11.21,在 /etc/named.conf 新增以下內容至檔案的最後面 :
:::info
在本次範例中
- Cluster name 是
topgun - Base Domain Name 是
kubeantony.com
:::
設定 DNS Server 名稱解析
檔案內容如下 :
$TTL 1W
@ IN SOA bastion.topgun.kubeantony.com. root (
2019070700 ; serial
3H ; refresh (3 hours)
30M ; retry (30 minutes)
2W ; expiry (2 weeks)
1W ) ; minimum (1 week)
IN NS bastion.topgun.kubeantony.com.
IN MX 10 smtp.kubeantony.com.
;
;
bastion.topgun.kubeantony.com. IN A 192.168.11.21
smtp.kubeantony.com. IN A 192.168.11.21
;
api.topgun.kubeantony.com. IN A 192.168.11.21
api-int.topgun.kubeantony.com. IN A 192.168.11.21
;
*.apps.topgun.kubeantony.com. IN A 192.168.11.21
;
master-1.topgun.kubeantony.com. IN A 192.168.11.23
master-2.topgun.kubeantony.com. IN A 192.168.11.24
master-3.topgun.kubeantony.com. IN A 192.168.11.25
;
worker-1.topgun.kubeantony.com. IN A 192.168.11.26
worker-2.topgun.kubeantony.com. IN A 192.168.11.27
worker-3.topgun.kubeantony.com. IN A 192.168.11.28
;
;EOF
:::danger
Note: 紅字部分為須依照環境的規劃來設定
:::
設定 DNS Server 反解析
檔案內容如下 :
$TTL 1W
@ IN SOA bastion.topgun.kubeantony.com. root (
2019070700 ; serial
3H ; refresh (3 hours)
30M ; retry (30 minutes)
2W ; expiry (2 weeks)
1W ) ; minimum (1 week)
IN NS bastion.topgun.kubeantony.com.
;
21.11.168.192.in-addr.arpa. IN PTR api.topgun.kubeantony.com.
21.11.168.192.in-addr.arpa. IN PTR api-int.topgun.kubeantony.com.
;
23.11.168.192.in-addr.arpa. IN PTR master-1.topgun.kubeantony.com.
24.11.168.192.in-addr.arpa. IN PTR master-2.topgun.kubeantony.com.
25.11.168.192.in-addr.arpa. IN PTR master-3.topgun.kubeantony.com.
;
26.11.168.192.in-addr.arpa. IN PTR worker-1.topgun.kubeantony.com.
27.11.168.192.in-addr.arpa. IN PTR worker-2.topgun.kubeantony.com.
28.11.168.192.in-addr.arpa. IN PTR worker-3.topgun.kubeantony.com.
;
;EOF
:::danger
Note: 紅字部分為須依照環境的規劃來設定
:::
啟動 DNS Server
螢幕輸出 :
檢查
螢幕輸出 :
● named.service - Berkeley Internet Name Domain (DNS)
Loaded: loaded (/usr/lib/systemd/system/named.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2023-07-17 16:50:31 CST; 1s ago
...以下省略
將 bastion 機器的 IP 新增為 DNS Server
關閉防火牆
驗證 DNS Server 正解
驗證 DNS Server 反解
Step 3: 安裝 HAProxy 服務
設定 HAProxy
直接清掉預設的設定檔
再編輯設定檔
將以下內容複製到檔案中 :
global
log 127.0.0.1 local2
pidfile /var/run/haproxy.pid
maxconn 4000
daemon
defaults
mode http
log global
option dontlognull
option http-server-close
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
listen api-server-6443
bind *:6443
mode tcp
server master-1 master-1.topgun.kubeantony.com:6443 check inter 1s
server master-2 master-2.topgun.kubeantony.com:6443 check inter 1s
server master-3 master-3.topgun.kubeantony.com:6443 check inter 1s
listen machine-config-server-22623
bind *:22623
mode tcp
server master-1 master-1.topgun.kubeantony.com:22623 check inter 1s
server master-2 master-2.topgun.kubeantony.com:22623 check inter 1s
server master-3 master-3.topgun.kubeantony.com:22623 check inter 1s
listen ingress-router-443
bind *:443
mode tcp
balance source
server worker-1 worker-1.topgun.kubeantony.com:443 check inter 1s
server worker-2 worker-2.topgun.kubeantony.com:443 check inter 1s
server worker-3 worker-3.topgun.kubeantony.com:443 check inter 1s
listen ingress-router-80
bind *:80
mode tcp
balance source
server worker-1 worker-1.topgun.kubeantony.com:80 check inter 1s
server worker-2 worker-2.topgun.kubeantony.com:80 check inter 1s
server worker-3 worker-3.topgun.kubeantony.com:80 check inter 1s
:::danger
Note: 紅字部分為須依照環境的規劃來設定
:::
設定允許 HAProxy 可以使用 TCP Port
If you are using HAProxy as a load balancer and SELinux is set to enforcing, you must ensure that the HAProxy service can bind to the configured TCP port by running setsebool -P haproxy_connect_any=1.
啟動 HAProxy 服務,並設為開機自動啟動
螢幕輸出 :
檢查
螢幕輸出 :
● haproxy.service - HAProxy Load Balancer
Loaded: loaded (/usr/lib/systemd/system/haproxy.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2023-07-17 17:26:21 CST; 11min ago
...以下省略
Step 4: 下載 pull-secret
至以下連結下載,注意 : 需先登入帳號

可點選 “Download pull secret",或是點 “Copy pull secret” 直接將 pull-secret 複製到剪貼簿
Step5: 編輯必要叢集設定檔
產生目錄
設定 install-config.yaml
檔案內容如下 :
install-config.yaml 欄位介紹
| 區塊 | 鍵名 / 值 | 說明 |
|---|
| 版本與網域 | apiVersion: v1 | 設定檔格式版本 |
| baseDomain: kubeantony.com | 集群基礎網域,與 metadata.name 組成完整 FQDN |
| metadata.name: topgun | 集群名稱,完整 FQDN 為 topgun.kubeantony.com |
| 控制平面 | controlPlane.name: master | 控制節點名稱 |
| controlPlane.replicas: 3 | 控制節點數量 |
| controlPlane.architecture: amd64 | 架構 |
| controlPlane.hyperthreading: Enabled | 是否啟用超執行緒 |
| 工作節點 | compute[0].name: worker | 工作節點名稱 |
| compute[0].replicas: 3 | 工作節點數量 |
| compute[0].architecture: amd64 | 架構 |
| compute[0].hyperthreading: Enabled | 是否啟用超執行緒 |
| 網路設定 | networking.networkType: OVNKubernetes | CNI 使用 OVN |
| clusterNetwork.cidr: 10.128.0.0/14 | Pod 網段 |
| clusterNetwork.hostPrefix: 23 | 每節點最大 Pod 數(約 512) |
| machineNetwork.cidr: 192.168.11.0/24 | 節點網路範圍 |
| serviceNetwork: 172.30.0.0/16 | Service 網段 |
| 平台 | platform.none: {} | 表示為裸機或 Agent-based 安裝 |
| 憑證與金鑰 | pullSecret: {...} | Red Hat container registry 認證用 |
| sshKey: '...' | 安裝後 SSH 公鑰 |
設定 agent-config.yaml
檔案內容如下 :
備份設定檔
產生安裝用 ISO
需要先安裝 nmstae 套件
再產生 ISO
螢幕輸出 :
Step6: 開始安裝 RedHat OpenShift
1. 將 ISO 上傳至虛擬化平台,並掛載到 VM 上
注意!如果是在 vsphere 的環境,需要幫每一台 VM 新增以下參數:
點選 vm -> edit settings -> Advanced Parameters
然後點選 ADD
2. 在虛擬化平台將各節點透過 ISO 開機

3. 追蹤和驗證安裝進度 (在 Bastion 主機執行以下指令)
確認哪些節點已安裝完畢,並需要重新開機:
:::danger
注意! 以上指令會提示你哪台 VM 已將所有東西都安裝進硬碟裡面,然後進入自動重新開機的階段,當你看到類似的提示訊息後,大約過 30 秒 ~ 2 分鐘內,該主機會自動重開,請確保該 VM 會透過硬碟重新開機,不要再透過 ISO 又開機進去。
:::
正確安裝的螢幕輸出如下 :
確認重開機後,OpenShift 自動安裝完成
螢幕輸出 :
設定 KubeConfig
檢查叢集節點狀態
螢幕輸出
檢視整個叢集核心元件是否健康
螢幕輸出 :