Flux 이벤트
Flux 이벤트 (Flux events)
Flux 컨트롤러는 reconciliation 작업 중에 Kubernetes 이벤트를 발생시켜서, reconcile 되고 있는 객체에 대한 정보를 제공해요. 이 문서는 이 이벤트가 어떤 필드로 구성되는지, 그리고 kubectl이나 flux CLI로 어떻게 조회·해석하는지 설명합니다.
출처: 문서
본문
Flux 컨트롤러는 reconciliation 작업 중에 Kubernetes 이벤트를 발생시켜 reconcile 되고 있는 객체에 대한 정보를 제공합니다. 로그와 달리 이벤트는 항상 특정 객체와 연결돼요 — 이 경우 그 객체는 Flux 리소스입니다. 이벤트는 로그와 함께 사용해 컨트롤러 작업의 완전한 그림을 제공할 수 있는 보조 데이터예요. Flux 컨트롤러가 발생시키는 이벤트 중 일부는 알림을 보내는 데도 사용됩니다. 컨트롤러의 이벤트에 기반한 Flux Alerts에 대해 자세히 알아보려면 Alerts 문서를 참조하세요. 아래 섹션에서는 Flux 이벤트와 그것을 해석하는 방법을 살펴볼게요.
Kubernetes 이벤트
Flux 컨트롤러 이벤트는 리소스에 대해 다음 필드를 포함합니다.
type—Normal또는Warning일 수 있어요firstTimestamp— ISO 8601 형식의 타임스탬프lastTimestamp— ISO 8601 형식의 타임스탬프message— 정보 또는 경고 설명reason— 짧고 기계가 이해할 수 있는 문자열involvedObject— Flux 객체의 API 버전, kind, 이름, 네임스페이스metadata.annotations— 소스 revision 같은 Flux 특정 메타데이터source.component— 이벤트가 발생한 Flux 컨트롤러 이름
예시 (Examples)
kustomize-controller가 만들어낸 Normal 이벤트 예시.
{
"kind": "Event",
"apiVersion": "v1",
"metadata": {
"name": "flux-system.177bd633e296a292",
"namespace": "flux-system",
"annotations": {
"kustomize.toolkit.fluxcd.io/revision": "main@sha1:802723078affd3eb2a3898630261ab3ca5d6dd40"
}
},
"involvedObject": {
"kind": "Kustomization",
"namespace": "flux-system",
"name": "flux-system",
"apiVersion": "kustomize.toolkit.fluxcd.io/v1",
},
"reason": "ReconciliationSucceeded",
"message": "Reconciliation finished in 436.493292ms, next run in 10m0s",
"source": {
"component": "kustomize-controller"
},
"firstTimestamp": "2023-08-16T10:26:43Z",
"lastTimestamp": "2023-08-16T10:26:43Z",
"type": "Normal",
}
위 예시에서 확인할 수 있는 것:
- 이 이벤트는
involvedObject필드가 나타내는 대로, flux-system 네임스페이스에 있는 flux-system이라는 이름의 Kustomization에 관한 것이에요. - 이 이벤트는
source.component필드가 나타내는 대로, kustomize-controller에서 발생했어요. - 이 이벤트는
reason과message필드가 나타내는 대로, 성공적인 reconciliation에 관한Normal유형 이벤트입니다. metadata.annotations필드의kustomize.toolkit.fluxcd.io/revision은 Kustomization의 성공적인 reconciliation 결과로 성공적으로 적용된 소스 revision 정보를 담고 있어요.
source-controller가 만들어낸 Warning 이벤트 예시.
{
"apiVersion": "v1",
"count": 4,
"eventTime": null,
"firstTimestamp": "2023-08-22T20:24:06Z",
"involvedObject": {
"apiVersion": "source.toolkit.fluxcd.io/v1",
"kind": "GitRepository",
"name": "podinfo",
"namespace": "default",
"resourceVersion": "1284973",
"uid": "2c2ed1da-556f-4793-863d-7d96e8bab3f5"
},
"kind": "Event",
"lastTimestamp": "2023-08-22T20:24:18Z",
"message": "failed to checkout and determine revision: unable to clone 'https://github.com/stefanprodan/podinfo': couldn't find remote ref \"refs/tags/v1.8.9\"",
"metadata": {
"creationTimestamp": "2023-08-22T20:24:06Z",
"name": "podinfo.177dce48bc7db3a4",
"namespace": "default",
"resourceVersion": "1285016",
"uid": "3c8f568a-c99b-4279-8093-6ef08fae325b"
},
"reason": "GitOperationFailed",
"reportingComponent": "",
"reportingInstance": "",
"source": {
"component": "source-controller"
},
"type": "Warning"
}
위 예시에서 확인할 수 있는 것:
- 이 이벤트는
involvedObject필드가 나타내는 대로, default 네임스페이스에 있는 podinfo라는 이름의 GitRepository에 관한 것이에요. - 이 이벤트는
source.component필드가 나타내는 대로, source-controller에서 발생했어요. - 이 이벤트는
reason과message필드가 나타내는 대로, 실패한 Git 작업에 관한Warning유형 이벤트입니다.
kubectl로 이벤트 확인하기
Flux 리소스와 연결된 이벤트는 kubectl events 명령으로 조회할 수 있어요.
$ kubectl events -n flux-system --for kustomization/flux-system
LAST SEEN TYPE REASON OBJECT MESSAGE
58m Normal ReconciliationSucceeded Kustomization/flux-system Reconciliation finished in 448.00332ms, next run in 10m0s
48m Normal ReconciliationSucceeded Kustomization/flux-system Reconciliation finished in 486.826649ms, next run in 10m0s
38m Normal ReconciliationSucceeded Kustomization/flux-system Reconciliation finished in 502.282127ms, next run in 10m0s
28m Normal ReconciliationSucceeded Kustomization/flux-system Reconciliation finished in 543.745587ms, next run in 10m0s
18m Normal ReconciliationSucceeded Kustomization/flux-system Reconciliation finished in 465.177441ms, next run in 10m0s
8m27s Normal ReconciliationSucceeded Kustomization/flux-system Reconciliation finished in 494.543068ms, next run in 10m0s
이렇게 하면 조회한 리소스와 연결된 한 시간 동안의 모든 이벤트를 보여줘요.
flux CLI로 이벤트 확인하기
Flux 리소스와 연결된 이벤트는 flux events CLI 명령으로 조회할 수 있습니다.
$ flux events --for Kustomization/flux-system
LAST SEEN TYPE REASON OBJECT MESSAGE
52m Normal ReconciliationSucceeded Kustomization/flux-system Reconciliation finished in 506.467ms, next run in 10m0s
42m Normal ReconciliationSucceeded Kustomization/flux-system Reconciliation finished in 531.072726ms, next run in 10m0
32m Normal ReconciliationSucceeded Kustomization/flux-system Reconciliation finished in 506.673992ms, next run in 10m0
22m Normal ReconciliationSucceeded Kustomization/flux-system Reconciliation finished in 512.255817ms, next run in 10m0
12m Normal ReconciliationSucceeded Kustomization/flux-system Reconciliation finished in 507.521248ms, next run in 10m0
2m31s Normal ReconciliationSucceeded Kustomization/flux-system Reconciliation finished in 448.00332ms, next run in 10m0s
이것은 모든 네임스페이스에 걸쳐 Flux 컨트롤러가 발생시킨 모든 이벤트를 실시간으로 보는 데에도 사용할 수 있어요.
$ flux events --all-namespaces --watch
NAMESPACE LAST SEEN TYPE REASON OBJECT MESSAGE
flux-system 34m (x3 over 154m) Normal GitOperationSucceeded GitRepository/flux-system no changes since last reconcilation: observed revision 'main@sha1:4d768edba5d409feb60870dd3b0ac0d307299898'
flux-system 54m Normal ReconciliationSucceeded Kustomization/flux-system Reconciliation finished in 486.814878ms, next run in 10m0s
flux-system 44m Normal ReconciliationSucceeded Kustomization/flux-system Reconciliation finished in 486.203813ms, next run in 10m0s
flux-system 34m Normal ReconciliationSucceeded Kustomization/flux-system Reconciliation finished in 512.160373ms, next run in 10m0s
flux-system 24m Normal ReconciliationSucceeded Kustomization/flux-system Reconciliation finished in 543.806383ms, next run in 10m0s
flux-system 14m Normal ReconciliationSucceeded Kustomization/flux-system Reconciliation finished in 524.293527ms, next run in 10m0s
flux-system 4m5s Normal ReconciliationSucceeded Kustomization/flux-system Reconciliation finished in 522.671955ms, next run in 10m0s
flux-system 47s Normal ReconciliationSucceeded Kustomization/flux-system Reconciliation finished in 523.892245ms, next run in 10m0s
flux-system 34m Normal ReconciliationSucceeded Kustomization/monitoring-configs Reconciliation finished in 104.609707ms, next run in 1h0m0s
flux-system 42s Normal ReconciliationSucceeded Kustomization/monitoring-configs Reconciliation finished in 90.70521ms, next run in 1h0m0s
flux-system 34m Normal ReconciliationSucceeded Kustomization/monitoring-controllers Reconciliation finished in 118.651968ms, next run in 1h0m0s
flux-system 39s Normal ReconciliationSucceeded Kustomization/monitoring-controllers Reconciliation finished in 132.34839ms, next run in 1h0m0s
monitoring 34m (x3 over 154m) Normal ArtifactUpToDate HelmChart/monitoring-kube-prometheus-stack artifact up-to-date with remote revision: '48.3.3'
monitoring 34m (x3 over 154m) Normal ArtifactUpToDate HelmChart/monitoring-loki-stack artifact up-to-date with remote revision: '2.9.11'
이에 대해 더 자세히 알아보려면 flux events CLI 문서를 참조하세요.