設定檔適用性:等級 1
在發生資料外洩時,將日誌和指標發送到遠端聚合器,以降低本地篡改的風險。
將日誌和指標匯出到專用的持久性資料存儲,如 GKE 的雲端運營,確保在叢集安全事件後審計資料的可用性,並提供一個集中位置資訊以分析從多個來源收集的日誌和指標資料。
注意從 GKE 版本 1.14 開始,預設已啟動記錄和雲端監控;對於較早的版本,預設已啟動傳統記錄和監控技術支援中心。
|
稽核
使用 Google Cloud 主控台:
日誌和雲端監控技術支援中心(優先):
- 前往 Google Cloud Console Kubernetes Engine 頁面 以訪問 Kubernetes Engine
- 從群集列表中,點擊您感興趣的群集。
- 在詳細資訊窗格中的功能部分,確保日誌記錄已啟動。
- 也請確保雲端監控已啟動。
舊版 Stackdriver 技術支援中心:
此選項無法在 GCP 控制台中勾選。
使用命令列:
日誌和雲端監控技術支援中心(優先):
首先定義三個變數:叢集名稱、位置資訊和專案,然後執行以下命令:
gcloud container clusters describe $CLUSTER_NAME --location $LOCATION -- project $PROJECT_ID --format json | jq '.loggingService' gcloud container clusters describe $CLUSTER_NAME --location $LOCATION -- project $PROJECT_ID --format json | jq '.monitoringService'
如果已啟動 Logging 和雲端監控,上述命令的輸出應分別返回
logging.googleapis.com/kubernetes 和 monitoring.googleapis.com/kubernetes。舊版 Stackdriver 技術支援中心:
注意此功能已於 2021 年 3 月 31 日停用,保留在此以供參考(請參閱:Google Cloud 文件以獲取詳細資訊)。
|
必須啟動日誌記錄和監控技術支援中心。
若要記錄,請執行下列命令:
gcloud container clusters describe $CLUSTER_NAME --location $LOCATION --project $PROJECT_ID --format json | jq '.loggingService'
如果已啟動舊版 Stackdriver Logging,則輸出應返回
logging.googleapis.com。監控時,執行下列命令:
gcloud container clusters describe $CLUSTER_NAME --location $LOCATION --project $PROJECT_ID --format json | jq '.monitoringService'
如果已啟動舊版 Stackdriver 監控,則輸出應返回
monitoring.googleapis.com。補救
使用 Google Cloud Console:啟用日誌記錄:
- 前往 Kubernetes Engine,請造訪:Google Cloud Console Kubernetes Engine 頁面。
- 選擇已停用記錄的叢集。
- 在詳細資訊窗格中的功能部分,點擊名為編輯日誌的鉛筆圖示。
- 勾選旁邊的啟用記錄選項。
- 在下拉式元件框中,選擇要記錄的元件。
- 點擊儲存變更,然後等待叢集更新。
啟用雲端監控:
- 前往 Kubernetes Engine,請造訪:Google Cloud Console Kubernetes Engine 頁面。
- 選擇已停用記錄的叢集。
- 在詳細資訊窗格中的功能部分,點擊名為編輯雲端監控的鉛筆圖示。
- 勾選旁邊的方框以啟用雲端監控。
- 在下拉式元件框中,選擇要記錄的元件。
- 點擊儲存變更,然後等待叢集更新。
使用命令列:
要為現有的叢集啟用日誌記錄,請執行以下命令:
gcloud container clusters update <cluster_name> --location <location> -- logging=<components_to_be_logged>
請參閱 GKE 指標文件 以獲取可用的日誌指標列表。
若要啟用現有叢集的雲端監控,請執行以下命令:
gcloud container clusters update <cluster_name> --location <location> -- monitoring=<components_to_be_logged>
請參閱GKE 日誌文件以獲取可用日誌值的列表。
