我在 AKS 中使用 HelmChart 部署了带有 docker 文件的 NodeJs 应用程序,并且我在 Azure 门户中拥有带有一些 key 的 azure key 保管库,并且我需要将正在运行的 POD 与该 KeyVault 连接。
最佳答案
我使用akv2k8s .
Akv2k8s 包含两个主要组件:
- akv2k8s Controller 将 Azure Key Vault 对象作为 native Secret 同步到 Kubernetes
- akv2k8s 注入(inject)器将 Azure Key Vault 对象作为环境变量直接注入(inject)到您的应用程序中。
图表:
在开始安装之前,我建议您阅读 How it works?页面。
稍后关注installation overview页面以设置环境。
如果您想使用 helm 安装 akv2k8s。我为我的 CI\CD 流程创建了这个代码片段:
# Create a dedicated namespace for akv2k8s
kubectl create ns akv2k8s
# Add Helm repository
helm repo add spv-charts http://charts.spvapi.no
helm repo update
# Install the Controller (and the "AzureKeyVaultSecret" CRD)
helm install azure-key-vault-controller spv-charts/azure-key-vault-controller --namespace akv2k8s
# Install the Env-Injector
helm install azure-key-vault-env-injector spv-charts/azure-key-vault-env-injector --set installCrd=false --namespace akv2k8s
简单example :
cat << EOF | kubectl apply -f -
apiVersion: spv.no/v1alpha1
kind: AzureKeyVaultSecret
metadata:
name: secret-sync
namespace: $(K8S_NAMESPACE)
spec:
vault:
name: ${KEY_VAULT_NAME} # name of key vault
object:
name: $(KEY_VALUT_OBJECT_NAME) # name of the akv object
type: $(KEY_VALUT_TYPE) # akv object type
EOF
关于node.js - 如何将 Azure-key-vault 与 AKS pod 连接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62878289/