2.7.3.3. Azure Key Vault에서 시크릿 마운트


Secrets Store CSI Driver Operator를 사용하여 Azure Key Vault의 시크릿을 OpenShift Container Platform의 CSI 볼륨에 마운트할 수 있습니다. Azure Key Vault의 시크릿을 마운트하려면 Microsoft Azure에 클러스터가 설치되어 있어야 합니다.

사전 요구 사항

  • 클러스터가 Azure에 설치되어 있습니다.
  • Secrets Store CSI Driver Operator가 설치되어 있습니다. 자세한 내용은 Secrets Store CSI 드라이버 설치를 참조하십시오.
  • 필요한 시크릿을 저장하도록 Azure Key Vault를 구성했습니다.
  • Azure CLI(az)를 설치했습니다.
  • cluster-admin 역할의 사용자로 클러스터에 액세스할 수 있어야 합니다.

프로세스

  1. Azure Key Vault 공급자를 설치합니다.

    1. 공급자 리소스에 대한 다음 구성을 사용하여 YAML 파일을 생성합니다.

      중요

      Secrets Store CSI 드라이버의 Azure Key Vault 공급자는 업스트림 공급자입니다.

      이 구성은 OpenShift Container Platform에서 제대로 작동하도록 업스트림 Azure 설명서에 제공된 구성에서 수정됩니다. 이 구성을 변경하면 기능에 영향을 미칠 수 있습니다.

      azure-provider.yaml 파일 예

      apiVersion: v1
      kind: ServiceAccount
      metadata:
        name: csi-secrets-store-provider-azure
        namespace: openshift-cluster-csi-drivers
      ---
      apiVersion: rbac.authorization.k8s.io/v1
      kind: ClusterRole
      metadata:
        name: csi-secrets-store-provider-azure-cluster-role
      rules:
      - apiGroups: [""]
        resources: ["serviceaccounts/token"]
        verbs: ["create"]
      - apiGroups: [""]
        resources: ["serviceaccounts"]
        verbs: ["get"]
      - apiGroups: [""]
        resources: ["pods"]
        verbs: ["get"]
      - apiGroups: [""]
        resources: ["nodes"]
        verbs: ["get"]
      ---
      apiVersion: rbac.authorization.k8s.io/v1
      kind: ClusterRoleBinding
      metadata:
        name: csi-secrets-store-provider-azure-cluster-rolebinding
      roleRef:
        apiGroup: rbac.authorization.k8s.io
        kind: ClusterRole
        name: csi-secrets-store-provider-azure-cluster-role
      subjects:
      - kind: ServiceAccount
        name: csi-secrets-store-provider-azure
        namespace: openshift-cluster-csi-drivers
      ---
      apiVersion: apps/v1
      kind: DaemonSet
      metadata:
        namespace: openshift-cluster-csi-drivers
        name: csi-secrets-store-provider-azure
        labels:
          app: csi-secrets-store-provider-azure
      spec:
        updateStrategy:
          type: RollingUpdate
        selector:
          matchLabels:
            app: csi-secrets-store-provider-azure
        template:
          metadata:
            labels:
              app: csi-secrets-store-provider-azure
          spec:
            serviceAccountName: csi-secrets-store-provider-azure
            hostNetwork: true
            containers:
              - name: provider-azure-installer
                image: mcr.microsoft.com/oss/azure/secrets-store/provider-azure:v1.4.1
                imagePullPolicy: IfNotPresent
                args:
                  - --endpoint=unix:///provider/azure.sock
                  - --construct-pem-chain=true
                  - --healthz-port=8989
                  - --healthz-path=/healthz
                  - --healthz-timeout=5s
                livenessProbe:
                  httpGet:
                    path: /healthz
                    port: 8989
                  failureThreshold: 3
                  initialDelaySeconds: 5
                  timeoutSeconds: 10
                  periodSeconds: 30
                resources:
                  requests:
                    cpu: 50m
                    memory: 100Mi
                  limits:
                    cpu: 50m
                    memory: 100Mi
                securityContext:
                  allowPrivilegeEscalation: false
                  readOnlyRootFilesystem: true
                  runAsUser: 0
                  capabilities:
                    drop:
                    - ALL
                volumeMounts:
                  - mountPath: "/provider"
                    name: providervol
            affinity:
              nodeAffinity:
                requiredDuringSchedulingIgnoredDuringExecution:
                  nodeSelectorTerms:
                  - matchExpressions:
                    - key: type
                      operator: NotIn
                      values:
                      - virtual-kubelet
            volumes:
              - name: providervol
                hostPath:
                  path: "/var/run/secrets-store-csi-providers"
            tolerations:
            - operator: Exists
            nodeSelector:
              kubernetes.io/os: linux

    2. 다음 명령을 실행하여 csi-secrets-store-provider-azure 서비스 계정에 대한 권한 권한을 부여합니다.

      $ oc adm policy add-scc-to-user privileged -z csi-secrets-store-provider-azure -n openshift-cluster-csi-drivers
    3. 다음 명령을 실행하여 공급자 리소스를 생성합니다.

      $ oc apply -f azure-provider.yaml
  2. 키 자격 증명 모음에 액세스할 서비스 주체를 생성합니다.

    1. 다음 명령을 실행하여 서비스 주체 클라이언트 시크릿을 환경 변수로 설정합니다.

      $ SERVICE_PRINCIPAL_CLIENT_SECRET="$(az ad sp create-for-rbac --name https://$KEYVAULT_NAME --query 'password' -otsv)"
    2. 다음 명령을 실행하여 서비스 주체 클라이언트 ID를 환경 변수로 설정합니다.

      $ SERVICE_PRINCIPAL_CLIENT_ID="$(az ad sp list --display-name https://$KEYVAULT_NAME --query '[0].appId' -otsv)"
    3. 다음 명령을 실행하여 서비스 주체 클라이언트 시크릿 및 ID를 사용하여 일반 시크릿을 생성합니다.

      $ oc create secret generic secrets-store-creds -n my-namespace --from-literal clientid=${SERVICE_PRINCIPAL_CLIENT_ID} --from-literal clientsecret=${SERVICE_PRINCIPAL_CLIENT_SECRET}
    4. secret -store.csi.k8s.io/used=true 레이블을 적용하여 공급자가 이 nodePublishSecretRef 시크릿을 찾을 수 있도록 합니다.

      $ oc -n my-namespace label secret secrets-store-creds secrets-store.csi.k8s.io/used=true
  3. 시크릿 공급자 클래스를 생성하여 시크릿 저장소 공급자를 정의합니다.

    1. SecretProviderClass 오브젝트를 정의하는 YAML 파일을 생성합니다.

      secret-provider-class-azure.yaml의 예

      apiVersion: secrets-store.csi.x-k8s.io/v1
      kind: SecretProviderClass
      metadata:
        name: my-azure-provider                 
      1
      
        namespace: my-namespace                 
      2
      
      spec:
        provider: azure                         
      3
      
        parameters:                             
      4
      
          usePodIdentity: "false"
          useVMManagedIdentity: "false"
          userAssignedIdentityID: ""
          keyvaultName: "kvname"
          objects: |
            array:
              - |
                objectName: secret1
                objectType: secret
          tenantId: "tid"

      1
      시크릿 공급자 클래스의 이름을 지정합니다.
      2
      시크릿 공급자 클래스의 네임스페이스를 지정합니다.
      3
      공급자를 azure 로 지정합니다.
      4
      공급자별 구성 매개변수를 지정합니다.
    2. 다음 명령을 실행하여 SecretProviderClass 오브젝트를 생성합니다.

      $ oc create -f secret-provider-class-azure.yaml
  4. 이 시크릿 공급자 클래스를 사용할 배포를 생성합니다.

    1. Deployment 오브젝트를 정의하는 YAML 파일을 생성합니다.

      deployment.yaml의 예

      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: my-azure-deployment                            
      1
      
        namespace: my-namespace                              
      2
      
      spec:
        replicas: 1
        selector:
          matchLabels:
            app: my-storage
        template:
          metadata:
            labels:
              app: my-storage
          spec:
            containers:
            - name: busybox
              image: k8s.gcr.io/e2e-test-images/busybox:1.29
              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: "my-azure-provider" 
      3
      
                  nodePublishSecretRef:
                    name: secrets-store-creds                
      4

      1
      배포 이름을 지정합니다.
      2
      배포의 네임스페이스를 지정합니다. 이는 시크릿 공급자 클래스와 동일한 네임스페이스여야 합니다.
      3
      시크릿 공급자 클래스의 이름을 지정합니다.
      4
      Azure Key Vault에 액세스하기 위한 서비스 주체 인증 정보가 포함된 Kubernetes 시크릿의 이름을 지정합니다.
    2. 다음 명령을 실행하여 Deployment 오브젝트를 생성합니다.

      $ oc create -f deployment.yaml

검증

  • Pod 볼륨 마운트의 Azure Key Vault에서 시크릿에 액세스할 수 있는지 확인합니다.

    1. Pod 마운트의 보안을 나열합니다.

      $ oc exec busybox-<hash> -n my-namespace -- ls /mnt/secrets-store/

      출력 예

      secret1

    2. Pod 마운트에서 보안을 확인합니다.

      $ oc exec busybox-<hash> -n my-namespace -- cat /mnt/secrets-store/secret1

      출력 예

      my-secret-value

Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 문서 정보

Legal Notice

Theme

© 2026 Red Hat
맨 위로 이동