我正在尝试在我的私人集群中使用
Secrets Store CSI Driver
安装 aks add-ons
。该集群是我公司订阅部署的,因此从官方资源拉取镜像时存在一些网络限制。
我们使用
Harbor
从官方存储库中提取图像,并且我们已经将注册表配置为从 mcr.microsoft.com
中提取,问题是当我们尝试使用 Microsoft 推荐的方法通过在 CLI 中运行来安装附加组件时
az aks enable-addons --addons azure-keyvault-secrets-provider --name myAKSCluster --resource-group myResourceGroup
显然,该图像正在尝试从
mcr.microsoft.com
中提取,并且我想使用来自 harbor harbor.mycompany.com
的自定义 URL。
如何设置从中提取图像的存储库?
我已经尝试过编辑
daemonset
,但由于某种原因,图像总是回到 mcr.microsoft.com
。
编辑 Daemon Set 后图像仍恢复为
mcr.microsoft.com
的原因在于 AKS 的附加管理。当 AKS 管理 Secrets Store CSI 驱动程序等附加组件时,它可以在更新或协调过程中自动恢复对底层资源(包括守护进程集)所做的任何手动更改。
作为解决方法,完全禁用 AKS 管理的加载项并使用 Helm 手动安装 Secrets Store CSI 驱动程序,您可以在其中控制图像源。
示例-
az aks disable-addons --addons azure-keyvault-secrets-provider --name myAKSCluster --resource-group myResourceGroup
现在 AKS 不会自动恢复守护进程集。
现在您可以使用 Helm 手动安装 Secrets Store CSI 驱动程序
helm repo add secrets-store-csi-driver https://azure.github.io/secrets-store-csi-driver-provider-azure/charts
helm repo update
创建一个
values.yaml
文件,在其中为 CSI 驱动程序和 Azure 提供程序指定自定义 Harbor 注册表
您可以参考这里。 大致是这样的-
image:
registry: harbor.mycompany.com
repository: azure/secrets-store-csi
tag: latest # Specify the correct tag
providerAzure:
image:
registry: harbor.mycompany.com
repository: azure/provider-azure
tag: latest # Specify the correct tag
linux:
resources: {}
logLevel: 2
使用 Helm 手动安装 Secrets Store CSI 驱动程序
helm install csi-secrets-store secrets-store-csi-driver/csi-secrets-store-provider-azure \
--namespace kube-system \
--values values.yaml
完成后,验证 DaemonSet 是否使用来自
harbor.mycompany.com
的图像
kubectl get daemonset csi-secrets-store -n kube-system -o yaml | grep "image"
因此,通过禁用 AKS 附加组件并手动使用 Helm 安装 Secrets Store CSI 驱动程序,您可以完全控制守护程序集配置,从而防止 AKS 恢复您的更改。