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

Flux OpenShift 설치

원문 보기 위키 갱신

Flux를 OpenShift 클러스터에 설치·구성하는 방법을 설명하는 문서예요. bootstrap에 필요한 권한과 RBAC 패치, 그리고 OperatorHub를 통한 설치 방법을 다룹니다.

출처: 문서

본문

필요한 권한 (Required permissions)

Flux를 bootstrap 하려면 명령을 실행하는 사람이 대상 OpenShift 클러스터에 대한 클러스터 관리자 권한을 가져야 합니다. 또한 bootstrap 커스터마이징 문서에서 설명하는 대로 Git 리포지토리를 준비해야 해요.

먼저 scc.yaml을 flux-system 디렉터리에 복사하세요. 이 매니페스트에는 Flux 컨트롤러가 OpenShift에서 non-root로 실행될 수 있게 하는 RBAC가 포함되어 있습니다.

그런 다음 scc.yaml과 다음 패치를 flux-system kustomization.yaml에 추가하세요.

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - gotk-components.yaml
  - gotk-sync.yaml
  - scc.yaml
patches:
  - patch: |
      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: all
      spec:
        template:
          spec:
            securityContext:
              $patch: delete
            containers:
              - name: manager
                securityContext:
                  runAsUser: 65534
                  seccompProfile:
                    $patch: delete      
    target:
      kind: Deployment
      labelSelector: app.kubernetes.io/part-of=flux
  - patch: |-
      - op: remove
        path: /metadata/labels/pod-security.kubernetes.io~1warn
      - op: remove
        path: /metadata/labels/pod-security.kubernetes.io~1warn-version      
    target:
      kind: Namespace
      labelSelector: app.kubernetes.io/part-of=flux

마지막으로 변경 사항을 Git 리포지토리에 push하고 flux bootstrap을 실행하세요.

OperatorHub

Flux는 Flux Operator를 사용해 Red Hat OpenShift 클러스터에 OperatorHub에서 직접 설치할 수 있습니다.

Flux Operator는 Flux 생태계의 일부인 오픈소스 프로젝트로, OpenShift에서 Flux 컨트롤러의 수명 주기 관리를 위한 선언적 API를 제공해요.

먼저 flux-system 네임스페이스에 Subscription 리소스를 만들어 Flux Operator를 설치하세요.

apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
  name: flux-operator
  namespace: flux-system
spec:
  channel: stable
  name: flux-operator
  source: operatorhubio-catalog
  sourceNamespace: olm
  config:
    env:
      - name: DEFAULT_SERVICE_ACCOUNT
        value: "flux-operator"

구독 후에는 .spec.cluster.type을 openshift로 설정한 FluxInstance 리소스를 만듭니다.

apiVersion: fluxcd.controlplane.io/v1
kind: FluxInstance
metadata:
  name: flux
  namespace: flux-system
  annotations:
    fluxcd.controlplane.io/reconcileEvery: "1h"
spec:
  distribution:
    version: "2.x"
    registry: "ghcr.io/fluxcd"
  components:
    - source-controller
    - kustomize-controller
    - helm-controller
    - notification-controller
    - image-reflector-controller
    - image-automation-controller
  cluster:
    type: openshift
    multitenant: true
    networkPolicy: true
    domain: "cluster.local"
  sync:
    kind: GitRepository
    url: "https://my-git-server.com/my-org/my-fleet.git"
    ref: "refs/heads/main"
    path: "clusters/my-cluster"
    pullSecret: "flux-system"

Flux 인스턴스를 구성하는 방법에 대한 자세한 내용은 다음 리소스를 참조하세요.

  • Flux controllers configuration
  • Flux instance customization
  • Cluster sync configuration
  • Flux controllers sharding
  • Flux monitoring and reporting
  • Using ResourceSets for Application Definitions

더 알아보기 (Learn more)