Azure Cloud 在版本 "secrets-store.csi.k8s.io/v1alpha1" 中没有类型 "SecretProviderClass" 的匹配项

Azure Cloud no matches for kind "SecretProviderClass" in version "secrets-store.csi.k8s.io/v1alpha1"

我在 azure 云中工作,想使用 Azure 中的文档添加一个简单的 ServiceProviderClass Azure / secrets-store-csi-driver-provider-azure 替换 secretkeyvaultNametenantId

apiVersion: secrets-store.csi.x-k8s.io/v1alpha1
kind: SecretProviderClass
metadata:
  name: azure-kvname
spec:
  provider: azure
  parameters:
    usePodIdentity: "false"         # [OPTIONAL] if not provided, will default to "false"
    keyvaultName: "kvname"          # the name of the KeyVault
    cloudName: ""          # [OPTIONAL for Azure] if not provided, azure environment will default to AzurePublicCloud 
    objects:  |
      array:
        - |
          objectName: secret1
          objectType: secret        # object types: secret, key or cert
          objectVersion: ""         # [OPTIONAL] object versions, default to latest if empty
    tenantId: "tid"                    # the tenant ID of the KeyVault  

当我尝试使用 Azure 云将它应用到我的集群时 Bash:

hacker@Azure:~$ kubectl apply -f secrets-provider.yaml
error: unable to recognize "secrets-provider.yaml.yaml": no matches for kind "SecretProviderClass" in version "secrets-store.csi.k8s.io/v1alpha1"

好像文档上到处都是种类和版本不兼容

问题其实很简单,secret-store-csi-driver还没有安装。因此,它没有被识别。基本上确保您遵循 pre-requisistes.

您可以从 Azure 云终端使用 Helm 安装驱动程序:

helm repo add secrets-store-csi-driver https://raw.githubusercontent.com/kubernetes-sigs/secrets-store-csi-driver/master/charts
helm install csi-secrets-store secrets-store-csi-driver/secrets-store-csi-driver

There is an ongoing issue with the driver secrets-store-csi-driver-provider-azure#259, for azure you need to explicitly specify --grpc-supported-providers=azure

现在可以使用了:

hacker@Azure:~$ kubectl apply -f secrets-provider.yaml
secretproviderclass.secrets-store.csi.x-k8s.io/azure-kvname created
hacker@Azure:~$ kubectl get SecretProviderClass
NAME           AGE
azure-kvname   39s

希望这会有所帮助。