基礎(chǔ)設(shè)施即代碼(IAC),Zalando Postgres Operator UI 入門
Postgres Operator UI 提供了一個圖形界面,方便用戶體驗數(shù)據(jù)庫即服務(wù)。一旦 database 和/或 Kubernetes (K8s) 管理員設(shè)置了 operator,其他團(tuán)隊就很容易創(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)建一個新集群
在頂部菜單中選擇 New cluster 選項并調(diào)整文本字段中的值。集群名稱由團(tuán)隊加給定名稱組成。可用選項包括啟用負(fù)載均衡器、卷大小、用戶和數(shù)據(jù)庫以及 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ù)庫: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 按鈕時應(yīng)用該清單。
集群啟動
清單應(yīng)用于 K8s 后,Postgres Operator 將創(chuàng)建所有必要的資源。在 UI status 頁面中可以很好地跟蹤此過程的進(jìn)度。
通常,啟動最多只需要 1 分鐘。如果您覺得流程卡住了,請單擊 Logs 按鈕檢查 operator 日志。如果日志看起來沒問題,但 UI 似乎卡住了,請檢查您是否配置了與 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 正在使用的每個 worker 的日志和隊列。可以配置并發(fā) worker 的數(shù)量。
配置:https://postgres-operator.readthedocs.io/en/latest/reference/operator_parameters/#general。
啟動完成后,您將看到集群地址路徑。啟用負(fù)載均衡器后,列出的路徑可用作連接 PostgreSQL 時的主機(jī)名。但是,請確保您的 IP 在指定的 allowedSourceRanges 范圍內(nèi)。
更新和刪除集群
創(chuàng)建的集群列在 PostgreSQL clusters 菜單下。您可以通過 Status 按鈕返回集群的 status 頁面。從這兩個菜單中,您可以選擇編輯清單、克隆或刪除集群。
克隆:https://postgres-operator.readthedocs.io/en/latest/user/#how-to-clone-an-existing-postgresql-cluster。
請注意,UI 中尚不支持所有清單選項。如果您嘗試將它們添加到編輯器視圖中,則不會產(chǎn)生效果。請改用 kubectl 命令。左側(cè)顯示的清單也將顯示以這種方式修補(bǔ)的參數(shù)。
- 清單選項:https://postgres-operator.readthedocs.io/en/latest/reference/cluster_manifest/。
刪除集群時,系統(tǒng)會要求您輸入其命名空間和名稱以確認(rèn)操作。