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

Flux Schema 인벤토리

원문 보기 위키 갱신

Flux Schema 인벤토리 (Inventory)

flux schema discover 명령은 GitOps 저장소에 대한 구조화된 인벤토리를 만들 수 있게 해 줘요. --output을 json 또는 yaml로 설정하면 되는데, 이 문서는 그 인벤토리 데이터의 구조를 설명드리기 위한 공식 Flux CLI 플러그인 문서예요.

출처: 문서

본문

flux schema discover 명령은 --output을 json 또는 yaml로 설정해서 GitOps 저장소의 구조화된 인벤토리를 내보낼 수 있어요. 봉투(envelope) 형태는 버전이 매겨져 있으며 inventory-v1beta1.json의 JSON Schema로 문서화돼 있어요.

사용법 (Usage)

flux schema discover ./my-gitops-repo -o json

인벤토리 데이터 뒤에 있는 분류 규칙은 저장소 디스커버리 가이드를 참고해 주세요.

봉투 (Envelope)

모든 인벤토리는 최상위 봉투에 담겨 있어요:

| Key | Description | | apiVersion | Inventory API version. Currently schema.plugin.fluxcd.io/v1beta1. | | kind | Inventory API kind. Currently Inventory. | | $schema | URL of the JSON Schema describing the envelope. | | inventory.reporter | Identity of the producer, e.g. flux-schema/0.3.0. | | inventory.timestamp | RFC 3339 UTC timestamp of the scan. | | inventory.summary | Aggregate counts: files, resources, lines-of-yaml. | | inventory.directories | Map of directory path to classification. | | inventory.resources | Map of apiVersion/Kind to resource count, for all resources. | | inventory.flux | Map of Flux resource kind to defining files and identities. |

모든 맵은 키가 정렬된 상태로 직렬화되기 때문에 출력이 결정적(deterministic)이고 diff에 친화적이에요.

디렉터리 (Directories)

directories는 스캔된 매니페스트가 포함된 모든 디렉터리와 Helm 차트·Terraform 디렉터리를 다음 네 가지 분류 중 하나로 매핑해요: kubernetes-manifests, kustomize-overlay, helm-chart, terraform-module. 경로는 스캔된 루트 기준 상대 경로이고 /로 구분되며, 루트 자체는 .이에요.

"directories": {
  "apps/base": "kustomize-overlay",
  "charts/podinfo": "helm-chart"
}

리소스 (Resources)

resources는 완전한 조사(census)예요. 즉 저장소의 모든 리소스를 apiVersion/Kind별로 센 값이에요. 어떤 종류(kind)의 정확한 API 버전도 파일을 열지 않고 확인할 수 있어요.

"resources": {
  "apps/v1/Deployment": 12,
  "cert-manager.io/v1/ClusterIssuer": 1,
  "helm.toolkit.fluxcd.io/v2/HelmRelease": 3
}

Flux

flux는 모든 Flux 사용자 정의 리소스를 찾아내요. 키는 단순한 종류(kind) 이름이에요 — 해당 리소스의 API 버전은 이미 resources에 명시돼 있거든요. 각 종류는 리소스를 정의한 파일 경로(스캔된 루트 기준 상대 경로)를 그 파일에 선언된 리소스 식별자(identity)로 매핑해요:

"flux": {
  "HelmRelease": {
    "apps/base/podinfo.yaml": ["podinfo/podinfo"]
  },
  "Kustomization": {
    "clusters/production/apps.yaml": ["flux-system/apps"],
    "clusters/staging/apps.yaml": ["flux-system/apps"]
  }
}

식별자는 namespace/name 형식이에요. 네임스페이스가 없는 리소스에서는 namespace/ 부분이 생략되고, 문서에 metadata.name이 없으면 이름은 -로 표시돼요. 여러 문서를 담은 파일은 문서 순서대로 식별자를 나열해요.

일반 Kubernetes 리소스는 항목별로 열거하지 않아요 — 큰 저장소에는 수천 개가 있을 수 있고, 이 조사 데이터와 디렉터리 맵을 합치면 충분히 정확하게 위치를 찾아낼 수 있거든요.

같은 종류가 두 개 이상의 API 버전에 존재할 때(보통 마이그레이션 중간 단계)에는 그 파일들이 kind 키 아래 병합되는 반면, resources는 각 버전을 여전히 따로 보고해요.

예시 (Example)

{
  "apiVersion": "schema.plugin.fluxcd.io/v1beta1",
  "kind": "Inventory",
  "$schema": "https://raw.githubusercontent.com/fluxcd/flux-schema/main/docs/inventory-v1beta1.json",
  "inventory": {
    "reporter": "flux-schema/0.3.0",
    "timestamp": "2026-06-11T10:30:00Z",
    "summary": {
      "files": 8,
      "resources": 8,
      "lines-of-yaml": 99
    },
    "directories": {
      "apps/base": "kustomize-overlay",
      "apps/overlays/prod": "kustomize-overlay",
      "charts/podinfo": "helm-chart",
      "clusters/prod": "kubernetes-manifests",
      "infra/tf": "terraform-module"
    },
    "resources": {
      "apps/v1/Deployment": 1,
      "fluxcd.controlplane.io/v1/FluxInstance": 1,
      "helm.toolkit.fluxcd.io/v2/HelmRelease": 1,
      "kustomize.toolkit.fluxcd.io/v1/Kustomization": 1,
      "source.toolkit.fluxcd.io/v1/GitRepository": 1,
      "source.toolkit.fluxcd.io/v1/OCIRepository": 1,
      "v1/ConfigMap": 1,
      "v1/Service": 1
    },
    "flux": {
      "FluxInstance": {
        "clusters/prod/instance.yaml": ["flux-system/flux"]
      },
      "GitRepository": {
        "clusters/prod/flux-system.yaml": ["flux-system/flux-system"]
      },
      "HelmRelease": {
        "apps/base/podinfo.yaml": ["podinfo/podinfo"]
      },
      "Kustomization": {
        "clusters/prod/flux-system.yaml": ["flux-system/apps"]
      },
      "OCIRepository": {
        "apps/base/podinfo.yaml": ["podinfo/podinfo"]
      }
    }
  }
}

더 알아보기 (Learn more)