Azure DevOps용 Flux bootstrap
Azure DevOps를 사용해 Flux를 bootstrap하는 방법을 소개합니다.
출처: 문서
본문
Azure DevOps Git 저장소를 진실의 원천(source of truth)으로 사용해 AKS 클러스터에 Flux를 설치하려면 flux bootstrap git 명령을 사용할 수 있습니다.
필요한 권한
Flux를 bootstrap하려면 명령을 실행하는 사람이 대상 Kubernetes 클러스터에 대해 클러스터 관리자 권한이 있어야 합니다. 또한 명령을 실행하는 사람이 Azure DevOps Git 저장소에 대해 pull 및 push 권한이 있어야 합니다.
Azure DevOps PAT
Azure API에 접근하기 위해 bootstrap 명령은 Git 저장소에 대한 pull 및 push 권한이 있는 Azure DevOps 개인용 액세스 토큰(personal access token, PAT)을 요구합니다.
Azure DevOps PAT를 생성하고 Flux 설치 및 기타 Kubernetes 리소스를 담을 새 저장소를 만드세요.
Azure DevOps PAT는 환경 변수로 내보낼 수 있습니다:
export GIT_PASSWORD=<token>
GIT_PASSWORD 환경 변수가 설정되지 않으면 bootstrap 명령이 토큰을 입력하라고 프롬프트합니다.
파이프를 사용해 토큰을 제공할 수도 있습니다. 예: echo "<token>" | flux bootstrap git.
DevOps PAT를 사용한 Bootstrap
토큰 기반 인증으로 저장소를 위한 bootstrap을 실행:
flux bootstrap git \
--token-auth=true \
--url=https://dev.azure.com/<org>/<project>/_git/<repo> \
--branch=main \
--path=clusters/my-cluster
--token-auth를 사용하면 CLI와 클러스터에서 실행되는 Flux 컨트롤러가 Azure DevOps PAT를 사용해 HTTPS로 Git 저장소에 접근합니다.
Azure DevOps PAT는 flux-system 네임스페이스 안에 flux-system이라는 이름의 Kubernetes Secret으로 클러스터에 저장된다는 점에 유의하세요.
토큰 회전
Azure DevOps PAT에는 만료일이 있습니다. 토큰이 만료되기 전에 회전하려면 클러스터에서 flux-system secret을 삭제하고 새 PAT로 새 것을 만들세요:
flux create secret git flux-system \
--url=https://dev.azure.com/<org>/<project>/_git/<repo> \
--username=git \
--password=<token>
SSH 키를 사용한 Bootstrap
Azure DevOps SSH는 RSA SHA-2 키에서만 작동합니다.
RSA SHA-2 키로 Flux를 구성하려면 DevOps를 로컬로 복제한 다음, bootstrap에 필요한 파일 구조를 다음으로 만드세요:
mkdir -p clusters/my-cluster/flux-system
touch clusters/my-cluster/flux-system/gotk-components.yaml \
clusters/my-cluster/flux-system/gotk-sync.yaml \
clusters/my-cluster/flux-system/kustomization.yaml
kustomization.yaml 파일을 편집해 다음 패치를 포함하세요:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- gotk-components.yaml
- gotk-sync.yaml
patches:
- patch: |
- op: add
path: /spec/template/spec/containers/0/args/-
value: --ssh-hostkey-algos=rsa-sha2-512,rsa-sha2-256
target:
kind: Deployment
name: (source-controller|image-automation-controller)
변경 사항을 커밋하고 업스트림으로 push:
git add -A && git commit -m "init flux" && git push
Azure DevOps와 호환되는 SSH 키 페어를 생성하려면 rsa-sha2-512 알고리즘으로 ssh-keygen을 사용해야 합니다:
ssh-keygen -t rsa-sha2-512
SSH 공개 키를 Azure DevOps에 업로드하세요. 자세한 내용은 Azure DevOps 문서를 참조하세요.
Azure DevOps 저장소의 SSH URL과 RSA SHA-2 개인 키로 bootstrap을 실행:
flux bootstrap git \
--url=ssh://git@ssh.dev.azure.com/v3/<org>/<project>/<repo> \
--branch=<branch> \
--ssh-hostkey-algos=rsa-sha2-512,rsa-sha2-256 \
--private-key-file=<path> \
--password=<password> \
--path=clusters/my-cluster
flux bootstrap git 명령을 사용하는 방법에 대한 자세한 내용은 일반 Git 서버 문서를 참조하세요.