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

GitHub

원문 보기 위키 갱신

External Secrets Operator는 GitHub와 통합해서 Kubernetes 시크릿을 GitHub Actions 시크릿이나 Dependabot 시크릿과 동기화해요.

출처: External Secrets

본문

제약사항 (Limitations)

GitHub provider는 write-only예요. GitHub REST API나 Dependabot secrets API를 사용해 GitHub Actions 또는 Dependabot 시크릿을 생성하고 업데이트하는 용도로 설계됐고, 시크릿 값을 가져오는(fetch) 기능은 지원하지 않아요.

GitHub provider 설정하기 (Configuring GitHub provider)

GitHub API는 GitHub provider 기능을 사용하려면 ESO 앱을 GitHub 조직에 설치해야 해요. 두 시크릿 타입 모두 동일한 App ID, installation ID, private key 인증을 사용해요. 대상 조직 또는 리포지토리 범위에서 Actions 시크릿용으로는 Secrets, Dependabot 시크릿용으로는 Dependabot secrets에 대해 앱에 읽기/쓰기 권한을 부여하세요.

시크릿 스토어 설정하기 (Configuring the secret store)

Kind=SecretStore에 github provider가 등록되어 있는지 확인하세요. provider를 등록하려면 appID, installationID, organization 프로퍼티가 필수예요. 추가로 인증(auth)도 제공해야 해요.

secretType을 Actions 또는 Dependabot으로 설정하세요. 이 필드를 생략하면 Actions가 기본값이라서 기존 스토어와 호환성을 유지할 수 있어요.

선택적으로 Actions의 repository와 environment 시크릿을 대상으로 하려면 repository와 environment 필드를 추가해야 해요. Dependabot 리포지토리 시크릿에는 repository 필드를 추가하면 돼요.

Secret type Organization Repository Environment
Actions Yes Yes Yes
Dependabot Yes Yes No

repository를 생략하면 조직(Organization) 범위가 사용돼요. secretType: Dependabot과 environment를 함께 쓰는 것은 유효하지 않아요.

조직 시크릿의 경우, 선택 필드인 orgSecretVisibility가 PushSecret으로 생성되는 시크릿의 가시성을 제어해요. 유효한 값은 all 또는 private예요. 설정하지 않으면 새 시크릿은 가시성이 all로 생성되고, 기존 시크릿은 GitHub에 이미 설정된 가시성을 그대로 유지해요. 업데이트할 때도 기존의 selected-repository 연결을 유지해요. 리포지토리 범위의 시크릿은 조직 가시성이나 selected-repository 연결을 사용하지 않아요.

apiVersion: external-secrets.io/v1
kind: SecretStore
metadata:
  name: github
spec:
  provider:
    # provider type: github
    github:
      secretType: Actions # Optional. Actions (default) or Dependabot
      appID: "**app ID goes here**"
      # url: Default "https://github.com/", for enterprise Github instances uncomment and add your domain like "https://github.domain.com/"
      # uploadURL: Default "https://github.com"
      auth:
        privateKey:
          name: github-app-private-key
          key: privateKey.pem
      installationID: "**installation ID goes here**"
      organization: "Github **organization name goes here**"
      #repository: "Optional. set this for repository/environment secrets"
      #environment: "Optional. set this for environment secrets"

참고: ClusterSecretStore를 사용할 때는 auth.privateKey에 시크릿이 위치한 네임스페이스를 namespace로 반드시 제공하세요.

외부 시크릿으로 밀어넣기 (Pushing to an external secret)

Kubernetes 시크릿을 외부 GitHub 시크릿과 동기화하려면 PushSecret을 만들어야 해요. 즉 Kind=PushSecret이 필요해요.

apiVersion: external-secrets.io/v1alpha1
kind: PushSecret
metadata:
  name: github-push-secret-example
spec:
  deletionPolicy: Delete
  refreshInterval: 10m0s # Refresh interval for which push secret will reconcile
  secretStoreRefs: # A list of secret stores to push secrets to
    - name: github # Must match SecretStore on the cluster
      kind: SecretStore
  selector:
    secret:
      name: EXTSERCRET # Remote Github actions secret that we want to sync with the kubernetes secret
  data:
    - match:
        secretKey: extsecret # Source Kubernetes secret key containing the secret
        remoteRef:
          remoteKey: EXTSECRET # Key of the kubernetes secret to push

더 알아보기 (Learn more)