Secrets Store CSI Driver: Kubelet의 모든 인스턴스와의 통신을 용이하게 하는 데몬셋이다.
kubectl get pods -n kube-system -l 'app in (secrets-store-csi-driver,secrets-store-provider-azure)'
# 설치가 안되어 있을 경우 하기 명령어로 설치 진행
az aks enable-addons --addons azure-keyvault-secrets-provider --name <aks-name> --resource-group <resourcegroup-name>
Azure Portal에서도 설정 가능
2. Azure Key Vault 생성
az keyvault create -n <keyvault-name> -g <resourcegroup-name> -l koreacentral
SecretProviderClass를 통해 Secrets Store CSI Driver에 드라이버 구성 및 공급자 별 매개변수를 제공한다.
SecretProviderClass를 통해 Azure Key Vault에서 가져올 값들을 기술한다.
objectname은 Azure Key Vault에 저장한 key, secret, cert의 이름이다.
# secretproviderclass.yaml
apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
name: azure-kvname-wi # needs to be unique per namespace
spec:
provider: azure
parameters:
usePodIdentity: "false"
clientID: "${USER_ASSIGNED_CLIENT_ID}" # Setting this to use workload identity
keyvaultName: ${KEYVAULT_NAME} # Set to the name of your key vault
cloudName: "" # [OPTIONAL for Azure] if not provided, the Azure environment defaults to AzurePublicCloud
objects: |
array:
- |
objectName: secret1 # Set to the name of your secret
objectType: secret # object types: secret, key, or cert
objectVersion: "" # [OPTIONAL] object versions, default to latest if empty
- |
objectName: key1 # Set to the name of your key
objectType: key
objectVersion: ""
tenantId: "${IDENTITY_TENANT}" # The tenant ID of the key vault
# 비밀 저장소에 보관된 비밀을 표시
kubectl exec busybox-secrets-store-inline -- ls /mnt/secrets-store/
# 저장소에 비밀을 표시
kubectl exec busybox-secrets-store-inline -- cat /mnt/secrets-store/ExampleSecret