【发布时间】:2022-01-06 07:36:21
【问题描述】:
通过使用 https://docs.microsoft.com/en-us/azure/aks/csi-secrets-store-nginx-tls 本文档的引用,我正在尝试将 TLS 机密从 AKV 获取到 AKS pod。 最初,我使用 User Assigned Managed Identity 创建并配置了 CSI driver configuration。
我已经执行了以下步骤:
- 使用 1 个节点池创建 AKS 群集。
- 创建 AKV。
- 创建的用户分配托管标识并将其分配给节点池,即分配给为 AKS 创建的 VMSS。
- 在 AKS 的 "kube-system" 命名空间中安装了 CSI Driver helm chart。并完成了执行此操作的所有要求。
- 已创建 TLS 证书和密钥。
- 通过使用 TLS 证书和密钥,创建 .pfx 文件。
- 在名为 "ingresscert" 的 AKV 证书中上传了该 .pfx 文件。
- 在 AKS 中创建了名为“ingress-test”的新命名空间。
- 在该命名空间中部署的secretProviderClass如下:
apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
name: azure-tls
spec:
provider: azure
secretObjects: # secretObjects defines the desired state of synced K8s secret objects
- secretName: ingress-tls-csi
type: kubernetes.io/tls
data:
- objectName: ingresscert
key: tls.key
- objectName: ingresscert
key: tls.crt
parameters:
usePodIdentity: "false"
useVMManagedIdentity: "true"
userAssignedIdentityID: "7*******-****-****-****-***********1"
keyvaultName: "*****-*****-kv" # the name of the AKV instance
objects: |
array:
- |
objectName: ingresscert
objectType: secret
tenantId: "e*******-****-****-****-***********f" # the tenant ID of the AKV instance
- 在同一个命名空间中部署了 nginx-ingress-controller helm chart,其中证书与应用程序绑定。
- 已部署的 Busy Box 部署如下:
apiVersion: apps/v1
kind: Deployment
metadata:
name: busybox-one
labels:
app: busybox-one
spec:
replicas: 1
selector:
matchLabels:
app: busybox-one
template:
metadata:
labels:
app: busybox-one
spec:
containers:
- name: busybox
image: k8s.gcr.io/e2e-test-images/busybox:1.29-1
command:
- "/bin/sleep"
- "10000"
volumeMounts:
- name: secrets-store-inline
mountPath: "/mnt/secrets-store"
readOnly: true
volumes:
- name: secrets-store-inline
csi:
driver: secrets-store.csi.k8s.io
readOnly: true
volumeAttributes:
secretProviderClass: "azure-tls"
---
apiVersion: v1
kind: Service
metadata:
name: busybox-one
spec:
type: ClusterIP
ports:
- port: 80
selector:
app: busybox-one
- 使用命令检查密码是否创建
kubectl get secret -n <namespaceName>
这里要注意的一件事是,如果我将 shell 与繁忙的盒子 pod 连接并转到我提供的用于挂载秘密的装载路径,我已经看到那里成功获取了秘密。但是这个秘密并没有显示在 AKS 的秘密列表中。
我已对所有 AKS、KV 和清单文件进行了故障排除,但没有找到任何东西。 如果我遗漏了什么或任何人对此有解决方案,请告诉我。
提前谢谢..!!!
【问题讨论】:
标签: azure kubernetes azure-aks csi