在 AKS 中保护 Kubernetes Secrets:使用 Azure Key Vault 结合托管和用户分配身份
内容提要
本文介绍了在Azure Kubernetes Service(AKS)中安全管理秘密的方法,包括集成Azure Key Vault和AKS、启用Secret Store CSI Driver以及使用VM Managed Identities和User Assigned Identities。通过这些方法可以提高Kubernetes Secrets的安全性。
延伸解读
Kubernetes Secrets 的默认风险
文章指出,Kubernetes Secrets 默认仅进行 base64 编码,而非加密。这意味着任何能访问集群或 etcd 数据库的人都可以轻松解码并获取敏感信息。因此,仅依赖 Kubernetes 原生 Secrets 存储密码、API 密钥等存在显著安全风险,建议使用外部秘密管理服务如 Azure Key Vault 来增强保护。
两种托管身份的适用场景
VM Managed Identity(系统分配)随 AKS 集群生命周期自动创建和删除,无需手动管理凭证,适合希望简化身份管理的场景。User Assigned Identity 作为独立 Azure 资源,可分配给多个资源,提供更灵活的控制,适合需要跨资源共享身份或独立于资源生命周期管理身份的情况。选择取决于对自动化与灵活性的权衡。
Secret Store CSI Driver 的集成作用
在 AKS 中启用 Secret Store CSI Driver 后,可以通过 SecretProviderClass 将 Azure Key Vault 中的秘密以卷的形式挂载到 Pod 中。这样应用程序无需在集群内直接存储凭证,而是通过托管身份动态获取秘密,从而降低凭证暴露风险,并简化秘密管理流程。
Q&A
如何在AKS中安全管理Kubernetes Secrets?
可以通过集成Azure Key Vault和启用Secret Store CSI Driver来安全管理Kubernetes Secrets。
什么是VM Managed Identities,它如何帮助管理Azure Key Vault的访问?
VM Managed Identities是自动创建的身份,简化了对Azure Key Vault的访问管理,无需手动管理凭证。
如何启用Secret Store CSI Driver?
可以在AKS集群创建时或通过更新现有集群来启用Secret Store CSI Driver。
User Assigned Identities与VM Managed Identities有什么区别?
User Assigned Identities是独立的Azure资源,可以跨多个资源共享,而VM Managed Identities与特定资源的生命周期绑定。
如何配置SecretProviderClass以使用VM Managed Identity?
需要在SecretProviderClass中设置useVMManagedIdentity为'true',并指定keyvaultName和其他参数。
使用Azure Key Vault和Secret Store CSI Driver的好处是什么?
这种集成显著提高了Kubernetes Secrets的安全性,简化了秘密管理,降低了凭证暴露的风险。