Skip to content2.3. 解壓縮檔案,並將 oc、openshift-install 和 kubectl 加至 PATH 環境變數
2.4. 確認 oc Command 版本
螢幕輸出 :
Client Version: 4.19.10
Kustomize Version: v5.5.0
2.5. 確認 openshift-install Command 版本
螢幕輸出 :
openshift-install 4.19.10
built from commit 87bc6d06e8abd759e92112b434a180c2ddff41f1
release image quay.io/openshift-release-dev/ocp-release@sha256:2f9145136fb387d43c7fff55b30a036c14eb96b0992c292274b6f543c6c33857
release architecture amd64
2.6. 確認 kubectl Command 版本
螢幕輸出 :
openshift-install 4.19.10
built from commit 87bc6d06e8abd759e92112b434a180c2ddff41f1
release image quay.io/openshift-release-dev/ocp-release@sha256:2f9145136fb387d43c7fff55b30a036c14eb96b0992c292274b6f543c6c33857
release architecture amd64
[bigred@bastion ~]$ kubectl version --client --output=yaml
clientVersion:
buildDate: "2025-08-26T15:03:13Z"
compiler: gc
gitCommit: 298429ba9831d1d72b89edd9beb82a6ee665c3b7
gitTreeState: clean
gitVersion: v1.32.1
goVersion: go1.23.9 (Red Hat 1.23.9-1.el9_6) X:strictfipsruntime
major: "1"
minor: "32"
platform: linux/amd64
kustomizeVersion: v5.5.0
2.7. 安裝 DNS Server
2.8. 編輯 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
:::
2.9. 設定 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
quay.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: 紅字部分為須依照環境的規劃來設定
:::
2.10. 設定 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: 紅字部分為須依照環境的規劃來設定
:::
2.11. 啟動 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
...以下省略
2.12. 將 bastion 機器的 IP 新增為 DNS Server
2.13. 關閉防火牆
2.14. 驗證 DNS Server 正解
2.15. 驗證 DNS Server 反解
2.16. 安裝 HAProxy 服務
2.17. 設定 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: 紅字部分為須依照環境的規劃來設定
:::
2.18. 設定允許 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.
2.19. 啟動 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
...以下省略
2.20. 下載 pull-secret
- 執行以下命令
- 至以下連結下載,注意 : 需先登入帳號
可點選 “Download pull secret",或是點 “Copy pull secret” 直接將 pull-secret.txt 複製到剪貼簿
3. 安裝 Project Quay Container Registry
3.1. 先決條件
- 2 個或以上的 virtual CPU
- 4 GB 或以上的記憶體
- 系統上至少需要約 30 GB 或以上的磁碟空間,可細分如下:
- 約 10 GB 的磁碟空間用於 Red Hat Enterprise Linux (RHEL) 作業系統。
- 約 10 GB 的磁碟空間用於 Podman 儲存,以運行三個容器 (container)。
- 約 10 GB 的磁碟空間用於 Project Quay 本地儲存。
- 已安裝
podman - 這台機器需可上網
3.2. 規劃一顆獨立的硬碟給 Project Quay
在 VM 新增一顆硬碟專門給 Project Quay 使用
檢查新的硬碟名稱
執行結果 :
將硬碟名稱設為變數
使用 parted 建立 GPT 分割區,從 1 MiB 到磁碟尾,並標記為 LVM 用途
將剛建立的分割區初始化為 LVM PV
建立名為 vg-data 的 VG
從 VG 中建立一 LV,利用全部剩餘空間並命名為 lv-quay
格式化 LV 為 XFS 檔案系統,以提供穩健且高效的儲存
建立 Project Quay 要使用的儲存目錄
修改目錄權限
將目錄設為開機自動掛載 lv 裝置上
將目錄掛載到 lv 裝置上
3.3. 確認已準備好 DNS A record
請執行以下命令查詢
執行結果:
3.4. 透過 Mirror Registry 安裝 Project Quay
Mirror Registry: 這應用程式能讓使用者透過一個簡單的命令列介面 (CLI) 工具,輕易地安裝 Quay 及其所需元件。其目的是提供一個映像檔倉庫 (registry),用以存放 OpenShift 的映像檔。
建立並切換專案工作目錄
下載並準備 mirror-registry 工具
將下載的工具包解壓縮到工作目錄中
執行安裝指令,並設定 Quay 的資料儲存路徑、主機名稱及初始管理員帳號密碼
成功執行結果 :
檢查 Quay、Redis 等相關 app container 是否已成功啟動
正確執行結果:
將 Quay 自動產生的根憑證 (rootCA.pem) 複製到系統的信任憑證目錄
更新系統的 CA 信任清單,讓 HTTPS 連線時能信任此憑證
使用 podman 登入 Quay 倉庫,確認帳號與連線皆正常
正確執行結果:
透過 systemd 查詢 Quay 相關服務的運行狀態
執行結果:
透過 systemd 重啟 Quay Pod (此操作會連帶重啟 Quay App 與 Redis 容器):
2. 透過 oc-mirror 下載並打包 openshift 叢集所需之 container image,並上傳至本地 project quay
切換工作目錄
下載 oc-mirror CLI 工具
將 oc-mirror 執行檔解壓縮至 $PATH 路徑中,使其可直接執行
建立存放 image 倉庫身份憑證檔案的標準目錄
將 Red Hat Pull Secret 移至標準認證路徑,用於從官方倉庫拉取 image
登入本地 Quay 倉庫,認證資訊會自動加入 config.json
備份已包含 Red Hat 和本地 Quay 認證的組合檔案
列出指定 OpenShift 版本 (4.18) 可用的 OperatorHub Catalog
執行結果:
列出特定 Catalog 中的所有 Operator Packages,並將結果存檔
從清單中搜尋特定 Operator,以確認其 package 名稱和可用的 channel
執行結果:
查詢與 OpenShift 4.19 版本相關的所有可用的 channel
執行結果:
列出 stable-4.19 channel 可安裝的 openshift 版本
執行結果:
建立存放鏡像 tar 檔的本地目錄
編輯 ImageSetConfiguration 設定檔,定義要鏡像的內容
檔案內容如下:
執行鏡像程序:根據設定檔從網路下載所有 image,並打包成一個 tar 檔存放在本地
確認 tar 檔已成功建立
執行結果:
將本地 tar 檔中的所有 image 推送至目標 Project Quay 倉庫
4. 編輯必要叢集設定檔
4.1. 設定 install-config.yaml
每個環境一定會不同的欄位:
networking.machineNetwork.cidr,這是叢集節點的網路。pullSecret 欄位的內容:jq -c . ~/ocp4/pull-secret.json。sshKey 欄位的內容:cat ~/.ssh/id_rsa.pub,如果沒有 ssh public key,可透過這命令產生:ssh-keygen -t rsa -P ''。additionalTrustBundle 欄位的內容 : cat /data/quay/root/quay-rootCA/rootCA.pem。- 透過指令將憑證用正確的格式寫入檔案:
- 安裝 yq
- 定義檔案路徑變數,方便閱讀
- 讀取憑證內容並透過 yq 寫入 YAML 檔案
imageContentSources.mirrors:將 quay.kubeantony.com:8443 換成你的 quay 的 FQDN:PORT
檔案內容如下:
4.2. 設定 agent-config.yaml
每個環境一定會不同的欄位:
rendezvousIP,請設為第一台 control-plane node 的 ipadditionalNTPSources,你環境的 ntp serverhosts.interfaces.macAddress,請填入每台節點的 mac addresshosts.networkConfig,請填入相關網路設定
檔案內容如下:
4.3. 產生安裝用 ISO
需要先安裝 nmstae 套件
備份設定檔
再產生 ISO
螢幕輸出 :
5. 開始安裝 RedHat OpenShift
5.1. 安裝步驟
將 ISO 上傳至虛擬化平台,並掛載到 VM 上
在虛擬化平台將各節點透過 ISO 開機

追蹤和驗證安裝進度 (在 Bastion 主機執行以下指令)
確認哪些節點已安裝完畢,並需要重新開機:
:::danger
注意! 以上指令會提示你哪台 VM 已將所有東西都安裝進硬碟裡面,然後進入自動重新開機的階段,當你看到類似的提示訊息後,大約過 30 秒 ~ 2 分鐘內,該主機會自動重開,請確保該 VM 會透過硬碟重新開機,不要再透過 ISO 又開機進去。
:::
正確安裝的螢幕輸出如下 :
確認重開機後,OpenShift 自動安裝完成
螢幕輸出 :
設定 KubeConfig
為當前使用者設定 oc 指令設定 Bash 自動補全
檢查叢集節點狀態
螢幕輸出
檢視整個叢集核心元件是否健康
螢幕輸出 :
5.2. Openshihift 完成安裝後一定要做的設定
禁用預設的 OperatorHub 來源,以便使用自訂的鏡像來源
列出 oc-mirror 指令產生的資訊
執行結果:
套用映像檔內容來源策略,將映像檔請求重新導向至本地鏡像倉庫
建立新的 CatalogSource,讓 Operator Lifecycle Manager (OLM) 從本地鏡像倉庫找到 Operator
匯出全域叢集拉取密鑰 (pull-secret) 到當前目錄下的 .dockerconfigjson 檔案
從拉取密鑰中移除 cloud.openshift.com 的認證資訊
使用更新後的內容(已移除 cloud.openshift.com)來更新叢集中的拉取密鑰
重新啟動 Insights Operator 以套用新的設定
檢查 Insights Operator 的 Pod 狀態,確認重啟成功
執行結果:
檢查 Insights Cluster Operator (CO) 的健康狀態,確認其正常運作
執行結果:
6. 參考文章