簡介
本文實作練習中,將在 GKE Cluster 運作環境中,採用內建支援的「Backup for GKE」服務,這項服務由兩個部份所組成,分別是 Google Cloud API 及 GKE Add-on (the Backup for GKE agent)。簡單來說,就是可以針對 GKE Cluster 中的工作負載進行「備份和還原」作業。
圖、Backup for GKE 元件運作示意圖
Task1 - Enable Backup for GKE
在開始本文實作之前,先將後續會使用到的相關組態設定值,例如,Zone, Region,
Project_ID, Backup_Plan, External IP Address...等,寫入到 Bash Shell
的環境變數中以便後續使用:
echo "export ZONE=us-central1-a" >> ~/.bashrc
echo "export REGION=us-central1" >> ~/.bashrc
echo "export PROJECT_ID=`gcloud config get-value core/project`" >> ~/.bashrc
echo "export BACKUP_PLAN=my-backup-plan" >> ~/.bashrc
source ~/.bashrc
echo "export EXTERNAL_ADDRESS=$(gcloud compute addresses describe app-address --format='value(address)' --region $REGION)" >> ~/.bashrc
source ~/.bashrc
執行「gcloud services enable gkebackup.googleapis.com」指令,啟用 Backup for GKE APIs 服務,這個動作要等蠻久的,本文實作環境等待約 20
分鐘後才順利啟用完畢。接著,執行下列指令在現有的 GKE 叢集中啟用「Backup for GKE」備份服務。
gcloud beta container clusters update lab-cluster \
--project=$PROJECT_ID \
--update-addons=BackupRestore=ENABLED \
--zone=$ZONE
啟用 Backup for GKE 備份服務完成後,執行下列指令確認是否啟用成功。
gcloud beta container clusters describe lab-cluster \
--project=$PROJECT_ID \
--zone=$ZONE | grep -A 1 gkeBackupAgentConfig:
GKE Backup and Restore - 系列文章
- GKE Backup and Restore | GSP1110
- (本文) GKE Backup and Restore - Task1 | GSP1110
- GKE Backup and Restore - Task2 | GSP1110
- GKE Backup and Restore - Task3 | GSP1110
- GKE Backup and Restore - Task4 | GSP1110
- GKE Backup and Restore - Task5 | GSP1110
- GKE Backup and Restore - Task6 | GSP1110
- GKE Backup and Restore - Task7 | GSP1110
- GKE Backup and Restore - Task8 | GSP1110
- GKE Backup and Restore - Task9 | GSP1110