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

Flux 설치

원문 보기 위키 갱신

Flux CLI와 Flux 컨트롤러를 설치하는 방법을 소개합니다.

출처: 문서

본문

Flux 프로젝트는 명령줄 도구(Flux CLI)와 일련의 Kubernetes 컨트롤러로 구성됩니다.

Flux를 설치하려면 먼저 flux CLI를 다운로드해야 합니다. 그 다음 CLI를 사용해 클러스터에 Flux 컨트롤러를 배포하고 첫 GitOps 전달 파이프라인을 구성할 수 있습니다.

사전 요구 사항 (Prerequisites)

Flux 설치를 수행하는 사람은 대상 Kubernetes 클러스터에 대한 클러스터 관리자 권한이 있어야 합니다.

Kubernetes 클러스터는 다음 버전 중 하나와 일치해야 합니다:

| Kubernetes 버전 | 최소 요구 버전 | | v1.34 | >= 1.34.1 | | v1.35 | >= 1.35.0 | | v1.36 및 이후 | >= 1.36.0 |

Kubernetes EOL

Flux는 예를 들어 1.32 같은 더 오래된 Kubernetes 버전에서도 작동할 수 있지만, EOL 버전을 프로덕션에서 실행하는 것은 권장하지 않으며 이 버전들에 대한 지원도 제공하지 않습니다.

Flux CLI 설치

Flux CLI는 모든 주요 플랫폼용 바이너리 실행 파일로 제공되며, 바이너리는 GitHub releases 페이지에서 다운로드할 수 있습니다.

  • Homebrew
  • Mise
  • bash
  • yay
  • nix
  • Chocolatey

macOS 및 Linux용 Homebrew 사용:

brew install fluxcd/tap/flux

macOS 및 Linux용 Mise 사용:

mise use -g flux2@latest

macOS 및 Linux용 Bash 사용:

curl -s https://fluxcd.io/install.sh | sudo bash

Arch Linux용 yay(또는 다른 AUR 헬퍼) 사용:

yay -S flux-bin

NixOS용 nix-env 사용:

nix-env -i fluxcd

Windows용 Chocolatey 사용:

choco install flux

flux bash 완성(completions)을 로드하도록 셸을 구성하려면 프로필에 추가하세요:

. <(flux completion bash)

zsh, fish, powershell도 각각의 하위 명령으로 지원됩니다.

kubectl과 flux가 포함된 컨테이너 이미지가 DockerHub와 GitHub에 있습니다:

  • docker.io/fluxcd/flux-cli:
  • ghcr.io/fluxcd/flux-cli:

Flux 컨트롤러 설치

Kubernetes 클러스터에 Flux를 설치하는 권장方式是 bootstrap 절차를 사용하는 것입니다.

Flux CLI로 Bootstrap

flux bootstrap 명령은 Kubernetes 클러스터에 Flux 컨트롤러를 배포하고, 컨트롤러가 Git 저장소에서 클러스터 상태를 동기화하도록 구성합니다. 컨트롤러 설치 외에도, bootstrap 명령은 Flux 매니페스트를 Git 저장소에 push하고 Flux가 Git에서 스스로 갱신하도록 구성합니다.

컨트롤러가 클러스터에 이미 있으면 bootstrap 명령이 필요에 따라 업그레이드를 수행합니다. Bootstrap은 멱등성(idempotent)이 있어서, 명령을 원하는 만큼 여러 번 실행해도 안전합니다.

bootstrap 명령을 실행한 후에는 Kubernetes API에 연결할 필요 없이 Git push로 (Flux 업그레이드 포함) 클러스터의 모든 작업을 수행할 수 있습니다.

Bootstrap 제공자

Flux는 deploy key 및 기타 인증 메커니즘의 초기 설정을 간소화하기 위해 인기 있는 Git 제공자와 통합됩니다:

  • Gitea
  • GitHub
  • GitLab
  • Bitbucket
  • Azure DevOps
  • Google Cloud Source
  • Oracle VBS Git Repositories

Git 제공자가 위 목록에 없으면, 어떤 Git 서버에서든 작동하는 일반 bootstrap 절차를 따르세요.

Bootstrap 구성

bootstrap 시점에 사용할 수 있는 다양한 구성 옵션이 있습니다:

  • 선택 구성 요소 설치
  • 공유 클러스터에 테넌트 격리 적용
  • AWS, Azure, GCP에서 워크로드 아이덴티티 사용

Flux를 커스터마이즈하는 더 많은 예시는 bootstrap 구성 섹션을 참조하세요.

Terraform으로 Bootstrap

bootstrap 절차는 registry.terraform.io에 게시된 Flux provider로 Terraform으로 구현할 수 있습니다.

이 provider는 Flux CLI가 하는 것과 같은 방식으로 Flux를 bootstrap하는 데 사용할 수 있는 flux_bootstrap_git라는 Terraform 리소스를 제공합니다.

fluxcd/terraform-provider-flux 저장소에서 이 provider에 사용 가능한 예시를 확인하세요.

Flux Operator로 Bootstrap

Flux Operator는 Flux 컨트롤러의 수명 주기 관리를 위한 선언적 API를 제공하는 Flux 생태계의 오픈 소스 프로젝트입니다.

이 operator는 Flux CLI bootstrap 절차의 대안을 제공하며, Git 저장소, OCI 아티팩트, 또는 S3 호환 저장소에서 클러스터 상태의 reconcile을 구성하는 옵션을 제공합니다.

Flux Operator 설치

flux-system 네임스페이스에 Flux Operator를 설치합니다. 예를 들어 Helm 사용:

helm install flux-operator oci://ghcr.io/controlplaneio-fluxcd/charts/flux-operator \
  --namespace flux-system \
  --create-namespace

Flux Operator는 Helm, Terraform, OpenTofu, OperatorHub 등 여러 방법으로 설치할 수 있습니다. 자세한 내용은 설치 가이드를 참조하세요.

Flux 인스턴스 구성

flux-system 네임스페이스에 flux라는 이름의 FluxInstance 리소스를 만들면 최신 Flux 안정 버전을 설치하고, GitHub Container Registry에 저장된 OCI 아티팩트에서 클러스터 상태를 동기화하도록 Flux 컨트롤러를 구성합니다:

apiVersion: fluxcd.controlplane.io/v1
kind: FluxInstance
metadata:
  name: flux
  namespace: flux-system
  annotations:
    fluxcd.controlplane.io/reconcileEvery: "1h"
    fluxcd.controlplane.io/reconcileTimeout: "10m"
spec:
  distribution:
    version: "2.x"
    registry: "ghcr.io/fluxcd"
    artifact: "oci://ghcr.io/controlplaneio-fluxcd/flux-operator-manifests"
  components:
    - source-controller
    - source-watcher
    - kustomize-controller
    - helm-controller
    - notification-controller
    - image-reflector-controller
    - image-automation-controller
  cluster:
    type: kubernetes
    size: medium
    multitenant: false
    networkPolicy: true
    domain: "cluster.local"
  kustomize:
    patches:
      - target:
          kind: Deployment
        patch: |
          - op: replace
            path: /spec/template/spec/nodeSelector
            value:
              kubernetes.io/os: linux
          - op: add
            path: /spec/template/spec/tolerations
            value:
              - key: "CriticalAddonsOnly"
                operator: "Exists"          
  sync:
    kind: OCIRepository
    url: "oci://ghcr.io/my-org/my-fleet-manifests"
    ref: "latest"
    path: "clusters/my-cluster"
    pullSecret: "ghcr-auth"

Git 저장소, 컨테이너 레지스트리, S3 호환 저장소에서 동기화를 구성하는 방법에 대한 자세한 내용은 클러스터 동기화 가이드를 참조하세요.

operator는 새 버전이 나오면 Flux 컨트롤러와 해당 CRD를 자동으로 업그레이드할 수 있습니다. 업그레이드를 패치 버전으로만 제한하려면 distribution.version 필드를 예: 2.7.x로 설정하고, 자동 업그레이드를 비활성화하려면 고정 버전 예: 2.7.0으로 설정하세요.

Flux Operator는 Flux CLI나 다른 도구의 기존 설치 관리를 인수할 수 있습니다. 단계별 가이드는 Flux Operator 마이그레이션 가이드를 참조하세요.

개발용 설치 (Dev install)

테스트 목적으로 Git 저장소에 매니페스트를 저장하지 않고 Flux 컨트롤러를 설치할 수 있습니다.

flux로 설치:

flux install

kubectl로 설치:

kubectl apply -f https://github.com/fluxcd/flux2/releases/latest/download/install.yaml

helm으로 설치:

helm install -n flux-system --create-namespace flux oci://ghcr.io/fluxcd-community/charts/flux2

Helm 지원

Helm 차트는 fluxcd-community가 릴리스 주기 보장 없이 best effort 방식으로 유지 관리한다는 점에 유의하세요.

더 알아보기 (Learn more)

  • Flux bootstrap: 다양한 Git 제공자에 대해 Flux를 bootstrap하는 방법
  • Flux configuration: bootstrap 중에 Flux를 구성하는 방법
  • Flux upgrade: Flux CLI와 컨트롤러 업그레이드
  • Flux uninstall: Flux 컨트롤러를 제거하는 방법