使用 Cloud Code for VS Code 在 Kubernetes 中儲存機密資訊
本頁面提供 Kubernetes 機密的簡介,以及 Cloud Code 如何協助啟用 Secret Manager API 來建立、使用及儲存機密。
Kubernetes 密鑰簡介
建立 Kubernetes 應用程式時,通常需要傳遞少量機密資料,例如密碼、SSH 金鑰或 OAuth 權杖。您可以建立 Kubernetes 機密,用來儲存機密資料,而非將這類資訊儲存在 Pod 規格或容器映像檔中。
根據預設,Kubernetes 機密資料會以未加密的形式儲存在 API 伺服器的基礎資料儲存庫中。凡是有 API 存取權的使用者,都能擷取或修改密鑰。Kubernetes 密鑰文件建議您至少採取下列步驟,才能安全使用 Kubernetes 密鑰:
Cloud Code 中的 Secret Manager
Cloud Code 可協助您使用 Secret Manager API,在 IDE 中透過靜態資料加密功能建立、版本化及儲存 Secret。您可以專門在 Cloud Code 中使用 Secret Manager,也可以搭配您用於密鑰管理的其他工具使用。
在 IDE 中使用 Cloud Code 時,可執行的動作包括:
在 Cloud Code 中使用 Kubernetes 密鑰
如需在 Cloud Code 中建立、控管版本、使用及刪除密鑰的逐步操作說明,請參閱「管理密鑰」。
後續步驟
取得支援
如要提供意見回饋,請前往
GitHub 回報問題,或在
Stack Overflow 上提問。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-11 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-08-11 (世界標準時間)。"],[[["\u003cp\u003eKubernetes secrets are used to store sensitive data like passwords and tokens, rather than storing them directly in pod specifications or container images.\u003c/p\u003e\n"],["\u003cp\u003eBy default, Kubernetes secrets are stored unencrypted, so it is recommended to enable encryption at rest, configure RBAC rules, and consider external secret store providers.\u003c/p\u003e\n"],["\u003cp\u003eCloud Code enables users to leverage the Secret Manager API to create, version, and securely store secrets with encryption at rest directly from within the IDE.\u003c/p\u003e\n"],["\u003cp\u003eWith Cloud Code, you can enable the Secret Manager API, create and manage Kubernetes secrets, add them as environment variables, and mount them as volumes.\u003c/p\u003e\n"],["\u003cp\u003eThe Kubernetes Documentation provides further insight into the good practices and alternatives to secrets, such as service account tokens.\u003c/p\u003e\n"]]],[],null,[]]