본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

ClusterSecretStore

원문 보기 위키 갱신

ClusterSecretStore는 클러스터 범위(cluster scoped)의 SecretStore예요. 모든 네임스페이스의 모든 ExternalSecret이 참조할 수 있어서, 여러분의 시크릿 백엔드로 가는 중앙 게이트웨이를 만들 때 사용해요.

출처: External Secrets

본문

ClusterSecretStore는 이름 그대로 클러스터 전체에서 공유하는 SecretStore예요. 일반 SecretStore는 특정 네임스페이스에 묶이지만, ClusterSecretStore는 클러스터의 모든 네임스페이스에서 참조할 수 있답니다. 그래서 여러 팀이 함께 쓰는 중앙 시크릿 게이트웨이를 만들 때 딱 좋아요.

주요 특징

  • 클러스터 범위: 모든 네임스페이스의 ExternalSecret이 참조할 수 있어요.
  • provider별 지원 차이: 각 Store Provider는 안정성, 유지보수 상태, 지원 범위가 달라요. 도입 전에 Stability Support 문서를 꼭 확인하세요.
  • 미유지보수 스토어 경고: 명시적인 관리자(maintainer)가 없는 provider는 Admission webhook과 컨트롤러가 경고 이벤트를 발생시켜요. 컨트롤러 경고는 SecretStore에 external-secrets.io/ignore-maintenance-checks: "true" 어노테이션을 추가하면 끌 수 있지만, Admission webhook 경고는 끌 수 없어요.

Example

지원되는 필드 전체 목록은 spec 문서를 보거나 가이드를 살펴보세요.

apiVersion: external-secrets.io/v1
kind: ClusterSecretStore
metadata:
  name: example
  annotations:
    ## Add this annotation to disable controller warning events for unmaintained stores
    external-secrets.io/ignore-maintenance-checks: "true"
spec:
  # Used to select the correct ESO controller (think: ingress.ingressClassName)
  # The ESO controller is instantiated with a specific controller name
  # and filters ES based on this property
  # Optional
  controller: dev

  # provider field contains the configuration to access the provider
  # which contains the secret exactly one provider must be configured.
  provider:
    # (1): AWS Secrets Manager
    # aws configures this store to sync secrets using AWS Secret Manager provider
    aws:
      service: SecretsManager
      # Role is a Role ARN which the SecretManager provider will assume
      role: iam-role
      # AWS Region to be used for the provider
      region: eu-central-1
      # Auth defines the information necessary to authenticate against AWS
      auth:
        # Getting the accessKeyID and secretAccessKey from an already created Kubernetes Secret
        secretRef:
          accessKeyIDSecretRef:
            namespace: external-secrets
            name: awssm-secret
            key: access-key
          secretAccessKeySecretRef:
            namespace: external-secrets
            name: awssm-secret
            key: secret-access-key
        # IAM roles for service accounts
        # https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts-technical-overview.html
        jwt:
          serviceAccountRef:
            name: my-serviceaccount
            namespace: sa-namespace

    vault:
      server: "https://vault.acme.org"
      # Path is the mount path of the Vault KV backend endpoint
      # Used as a path prefix for the external secret key
      path: "secret"
      # Version is the Vault KV secret engine version.
      # This can be either "v1" or "v2", defaults to "v2"
      version: "v2"
      # vault enterprise namespace: https://www.vaultproject.io/docs/enterprise/namespaces
      namespace: "a-team"
      # base64 encoded string of certificate
      caBundle: "..."
      # Instead of caBundle you can also specify a caProvider
      # this will retrieve the cert from a Secret or ConfigMap
      caProvider:
        # Can be Secret or ConfigMap
        type: "Secret"
        # namespace is mandatory for ClusterSecretStore and not relevant for SecretStore
        namespace: "my-cert-secret-namespace"
        name: "my-cert-secret"
        key: "cert-key"
      auth:
        # static token: https://www.vaultproject.io/docs/auth/token
        tokenSecretRef:
          name: "my-secret"
          namespace: "secret-admin"
          key: "vault-token"

        # AppRole auth: https://www.vaultproject.io/docs/auth/approle
        appRole:
          path: "approle"
          # Instead of referencing the AppRole's ID from the secret, you can also specify it directly
          # roleId: "db02de05-fa39-4855-059b-67221c5c2f63"
          roleRef:
            name: "my-secret"
            namespace: "secret-admin"
            key: "vault-role-id"
          secretRef:
            name: "my-secret"
            namespace: "secret-admin"
            key: "vault-role-secret"

        # Kubernetes auth: https://www.vaultproject.io/docs/auth/kubernetes
        kubernetes:
          mountPath: "kubernetes"
          role: "demo"
          # Optional service account reference
          serviceAccountRef:
            name: "my-sa"
            namespace: "secret-admin"
          # Optional secret field containing a Kubernetes ServiceAccount JWT
          # used for authenticating with Vault
          secretRef:
            name: "my-secret"
            namespace: "secret-admin"
            key: "vault"

    # (2): GCP Secret Manager
    gcpsm:
      # Auth defines the information necessary to authenticate against GCP by getting
      # the credentials from an already created Kubernetes Secret.
      auth:
        secretRef:
          secretAccessKeySecretRef:
            name: gcpsm-secret
            key: secret-access-credentials
            namespace: example
      projectID: myproject

    # (3): Kubernetes provider
    kubernetes:
      server:
        url: "https://myapiserver.tld"
        caProvider:
          type: Secret
          name: my-cluster-secrets
          namespace: example
          key: ca.crt
      auth:
        serviceAccount:
          name: "example-sa"
          namespace: "example"

    # (4): Oracle provider
    oracle:
      # The vault OCID
      vault: ocid1.vault.oc1.eu-frankfurt-1.aaa1aaaaaaaaa.aaaaaaaaaaaaaa1aaaaaaa111aaaaaaaaaaaaaaaa
      # The vault region
      region: eu-frankfurt-1
      auth:
        # The user OCID
        user: ocid1.user.oc1..aaa1aaaaaaaaa.aaaaaaaaaaaaaa1aaaaaaa111aaaaaaaaaaaaaaaa
        # The tenancy OCID
        tenancy: ocid1.tenancy.oc1..aaa1aaaaaaaaa.aaaaaaaaaaaaaa1aaaaaaa111aaaaaaaaaaaaaaaa
        secretRef:
          privatekey:
            # The secret that contains your privatekey
            name: oci-secret-name
            key: privateKey
            namespace: example-namespace
          fingerprint:
            # The secret that contains your fingerprint
            name: oci-secret-name
            key: fingerprint
            namespace: example-namespace

    # (TODO): add more provider examples here

  # Conditions about namespaces in which the ClusterSecretStore is usable for ExternalSecrets
  conditions:
    # Options are namespaceSelector, namespaces or namespacesRegex
    - namespaceSelector:
        matchLabels:
          my.namespace.io/some-label: "value" # Only namespaces with that label will work

    - namespaces:
        - "namespace-a"
        - "namespace-b"

    # Namespace regexes are useful for policy management or when external tools auto-generate namespaces with prefixes/suffixes
    - namespaceRegexes:
        - "namespace-a-.*" # All namespaces prefixed by namespace-a- will work
        - "namespace-b-.*" # All namespaces prefixed by namespace-b- will work

    # conditions needs only one of the conditions to meet for the CSS to be usable in the namespace.

status:
  # Standard condition schema
  conditions:
    # SecretStore ready condition indicates the given store is in ready
    # state and able to referenced by ExternalSecrets
    # If the `status` of this condition is `False`, ExternalSecret controllers
    # should prevent attempts to fetch secrets
    - type: Ready
      status: "False"
      reason: "ValidationFailed"
      message: "SecretStore validation failed"
      lastTransitionTime: "2019-08-12T12:33:02Z"

위 예시는 여러 provider(AWS, Vault, GCP, Kubernetes, Oracle)의 설정을 모두 보여주지만, 실제로는 딱 하나의 provider만 설정해야 해요.

  • controller 필드는 어떤 ESO 컨트롤러가 이 스토어를 처리할지 선택해요 (ingress의 ingressClassName과 비슷한 개념).
  • conditions는 ClusterSecretStore를 사용할 수 있는 네임스페이스를 제한해요. namespaceSelector, namespaces, namespaceRegexes 중 하나만 충족하면 되고, 이 조건들은 OR로 동작해요.

더 알아보기 (Learn more)