基礎(chǔ)設(shè)施即代碼(IAC),Zalando Postgres Operator UI 入門
Postgres Operator UI 提供了一個(gè)圖形界面,方便用戶體驗(yàn)數(shù)據(jù)庫(kù)即服務(wù)。一旦 database 和/或 Kubernetes (K8s) 管理員設(shè)置了 operator,其他團(tuán)隊(duì)就很容易創(chuàng)建、克隆、監(jiān)視、編輯和刪除自己的 Postgres 集群。有關(guān)設(shè)置和技術(shù)細(xì)節(jié)的信息可以在 admin 文檔中找到。
admin 文檔: https://postgres-operator.readthedocs.io/en/latest/administrator/#setting-up-the-postgres-operator-ui。
創(chuàng)建一個(gè)新集群
在頂部菜單中選擇 New cluster 選項(xiàng)并調(diào)整文本字段中的值。集群名稱由團(tuán)隊(duì)加給定名稱組成。可用選項(xiàng)包括啟用負(fù)載均衡器、卷大小、用戶和數(shù)據(jù)庫(kù)以及 pod 資源。
- 啟用負(fù)載均衡器: https://postgres-operator.readthedocs.io/en/latest/administrator/#load-balancers-and-allowed-ip-ranges。
- 卷大小:https://postgres-operator.readthedocs.io/en/latest/user/#increase-volume-size
- 用戶和數(shù)據(jù)庫(kù):https://postgres-operator.readthedocs.io/en/latest/user/#manifest-roles
- pod 資源:https://postgres-operator.readthedocs.io/en/latest/operator-ui/cluster-manifest.md#postgres-container-resources。
在左側(cè),您將看到 Postgres 集群清單的預(yù)覽,當(dāng)單擊綠色的 Create cluster 按鈕時(shí)應(yīng)用該清單。
集群?jiǎn)?dòng)
清單應(yīng)用于 K8s 后,Postgres Operator 將創(chuàng)建所有必要的資源。在 UI status 頁(yè)面中可以很好地跟蹤此過(guò)程的進(jìn)度。
通常,啟動(dòng)最多只需要 1 分鐘。如果您覺(jué)得流程卡住了,請(qǐng)單擊 Logs 按鈕檢查 operator 日志。如果日志看起來(lái)沒(méi)問(wèn)題,但 UI 似乎卡住了,請(qǐng)檢查您是否配置了與 operator 相同的集群名稱標(biāo)簽。
- operator:https://github.com/zalando/postgres-operator/blob/master/manifests/configmap.yaml#L13。
- 集群名稱標(biāo)簽:https://github.com/zalando/postgres-operator/blob/master/ui/manifests/deployment.yaml#L45。
從頂部菜單的 Status 字段中,您還可以檢索 operator 正在使用的每個(gè) worker 的日志和隊(duì)列??梢耘渲貌l(fā) worker 的數(shù)量。
配置:https://postgres-operator.readthedocs.io/en/latest/reference/operator_parameters/#general。
啟動(dòng)完成后,您將看到集群地址路徑。啟用負(fù)載均衡器后,列出的路徑可用作連接 PostgreSQL 時(shí)的主機(jī)名。但是,請(qǐng)確保您的 IP 在指定的 allowedSourceRanges 范圍內(nèi)。
更新和刪除集群
創(chuàng)建的集群列在 PostgreSQL clusters 菜單下。您可以通過(guò) Status 按鈕返回集群的 status 頁(yè)面。從這兩個(gè)菜單中,您可以選擇編輯清單、克隆或刪除集群。
克隆:https://postgres-operator.readthedocs.io/en/latest/user/#how-to-clone-an-existing-postgresql-cluster。
請(qǐng)注意,UI 中尚不支持所有清單選項(xiàng)。如果您嘗試將它們添加到編輯器視圖中,則不會(huì)產(chǎn)生效果。請(qǐng)改用 kubectl 命令。左側(cè)顯示的清單也將顯示以這種方式修補(bǔ)的參數(shù)。
- 清單選項(xiàng):https://postgres-operator.readthedocs.io/en/latest/reference/cluster_manifest/。
刪除集群時(shí),系統(tǒng)會(huì)要求您輸入其命名空間和名稱以確認(rèn)操作。