简体   繁体   English

如何从 Kubernetes 将秘密写入 HashiCorp Valut 或 Azure Key Vault?

[英]How to write secrets to HashiCorp Valut or Azure Key Vault from Kubernetes?

I have come across injectors/drivers/ et cetera for Kubernetes for most major secret providers, but the common theme with those solutions are that these only sync one-way, ie, only from the vault to the cluster.对于大多数主要的秘密提供者,我遇到过 Kubernetes 的注入器/驱动程序/等等,但这些解决方案的共同主题是它们只能单向同步,即只能从保险库到集群。 I want to be able to update the secrets too, from my Kubernetes cluster.我也希望能够从我的 Kubernetes 集群更新机密。

What is the recommended pattern for doing this?这样做的推荐模式是什么? (Apart from the obvious solution of writing a custom service that communicates with the vault) (除了编写与保险库通信的自定义服务的明显解决方案)

I'd say that this is an anti pattern, meaning you shouldn't do that.我会说这是一种反模式,这意味着你不应该那样做。

If you create your secret in k8s from file, that would mean you either have it in version control, something you should never do.如果您从文件中在 k8s 中创建您的秘密,那意味着您要么将其置于版本控制中,而这是您永远不应该做的事情。 Or you don't have it in version control or create it from literal, which is good, but than you neither have a change history/log nor a real documentation of your secret.或者您没有在版本控制中使用它,也没有从文字中创建它,这很好,但是您既没有更改历史记录/日志,也没有关于您的秘密的真实文档。 I guess that would explain, why the major secret providers don't support that.我想这可以解释为什么主要的秘密提供者不支持这一点。

You should set up the secret using the key vault and apply it to your cluster using Terraform for example.您应该使用密钥保管库设置机密,并使用例如 Terraform 将其应用到您的集群。

Terraform supports both azure key vault secret https://www.terraform.io/docs/providers/azurerm/r/key_vault_secret.html and Kubernetes secrets https://www.terraform.io/docs/providers/kubernetes/r/secret.html Terraform supports both azure key vault secret https://www.terraform.io/docs/providers/azurerm/r/key_vault_secret.html and Kubernetes secrets https://www.terraform.io/docs/providers/kubernetes/r/secret .html

You can simply import the key vault secret and use it in the k8s secret.您可以简单地导入密钥库机密并在 k8s 机密中使用它。 Every time you update the key vault secret, you apply the changes with Terraform.每次更新密钥保管库机密时,都会使用 Terraform 应用更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM