Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement reporting for Flux installation status and statistics #46

Merged
merged 8 commits into from
Jun 21, 2024

Conversation

stefanprodan
Copy link
Member

@stefanprodan stefanprodan commented Jun 20, 2024

FluxReport is an API that reflects the observed state of a Flux installation.
Its purpose is to aid in monitoring and troubleshooting Flux by providing information about the installed components and their readiness, the distribution details, reconcilers statistics, cluster sync status, etc.

A single custom resource of this kind can exist in a Kubernetes cluster with the name flux. The resource is automatically generated in the same namespace where the flux-operator is deployed and is updated by the operator at regular intervals.

Example

The following example shows a FluxReport custom resource generated on a cluster where Flux was deployed:

apiVersion: fluxcd.controlplane.io/v1
kind: FluxReport
metadata:
  name: flux
  namespace: flux-system
spec:
  components:
    - image: ghcr.io/fluxcd/helm-controller:v1.0.1@sha256:a67a037faa850220ff94d8090253732079589ad9ff10b6ddf294f3b7cd0f3424
      name: helm-controller
      ready: true
      status: 'Current Deployment is available. Replicas: 1'
    - image: ghcr.io/fluxcd/kustomize-controller:v1.3.0@sha256:48a032574dd45c39750ba0f1488e6f1ae36756a38f40976a6b7a588d83acefc1
      name: kustomize-controller
      ready: true
      status: 'Current Deployment is available. Replicas: 1'
    - image: ghcr.io/fluxcd/notification-controller:v1.3.0@sha256:c0fab940c7e578ea519097d36c040238b0cc039ce366fdb753947428bbf0c3d6
      name: notification-controller
      ready: true
      status: 'Current Deployment is available. Replicas: 1'
    - image: ghcr.io/fluxcd/source-controller:v1.3.0@sha256:161da425b16b64dda4b3cec2ba0f8d7442973aba29bb446db3b340626181a0bc
      name: source-controller
      ready: true
      status: 'Current Deployment is available. Replicas: 1'
  distribution:
    entitlement: Issued by controlplane
    managedBy: flux-operator
    status: Installed
    version: v2.3.0
  reconcilers:
    - apiVersion: helm.toolkit.fluxcd.io/v2
      kind: HelmRelease
      stats:
        failing: 1
        running: 42
        suspended: 3
    - apiVersion: kustomize.toolkit.fluxcd.io/v1
      kind: Kustomization
      stats:
        failing: 0
        running: 5
        suspended: 0
    - apiVersion: notification.toolkit.fluxcd.io/v1
      kind: Receiver
      stats:
        failing: 0
        running: 1
        suspended: 0
    - apiVersion: notification.toolkit.fluxcd.io/v1beta3
      kind: Alert
      stats:
        failing: 0
        running: 1
        suspended: 0
    - apiVersion: notification.toolkit.fluxcd.io/v1beta3
      kind: Provider
      stats:
        failing: 0
        running: 1
        suspended: 0
    - apiVersion: source.toolkit.fluxcd.io/v1
      kind: GitRepository
      stats:
        failing: 0
        running: 2
        suspended: 0
        totalSize: 3.7 MiB
    - apiVersion: source.toolkit.fluxcd.io/v1
      kind: HelmChart
      stats:
        failing: 1
        running: 55
        suspended: 0
        totalSize: 15.7 MiB
    - apiVersion: source.toolkit.fluxcd.io/v1
      kind: HelmRepository
      stats:
        failing: 0
        running: 7
        suspended: 3
        totalSize: 40.5 MiB
    - apiVersion: source.toolkit.fluxcd.io/v1beta2
      kind: Bucket
      stats:
        failing: 0
        running: 0
        suspended: 0
    - apiVersion: source.toolkit.fluxcd.io/v1beta2
      kind: OCIRepository
      stats:
        failing: 0
        running: 1
        suspended: 0
        totalSize: 78.1 KiB
  sync:
    id: kustomization/flux-system
    path: clusters/production
    ready: true
    source: https://github.com/my-org/my-fleet.git
    status: 'Applied revision: refs/heads/main@sha1:a90cd1ac35de01c175f7199315d3f4cd60195911'
status:
  conditions:
    - lastTransitionTime: "2024-06-20T19:59:30Z"
      message: Reporting finished in 272ms
      observedGeneration: 4
      reason: ReconciliationSucceeded
      status: "True"
      type: Ready
  1. Export the report in YAML format:

    kubectl -n flux-system get fluxreport/flux -o yaml
  2. Trigger a reconciliation of the report:

    kubectl -n flux-system annotate --overwrite fluxreport/flux \
     reconcile.fluxcd.io/requestedAt="$(date +%s)"
  3. Change the report reconciliation interval:

    kubectl -n flux-system annotate --overwrite fluxreport/flux \
     fluxcd.controlplane.io/reconcileEvery=5m
  4. Pause the report reconciliation:

    kubectl -n flux-system annotate --overwrite fluxreport/flux \
     fluxcd.controlplane.io/reconcile=disabled
  5. Resume the reconciliation of the report:

     kubectl -n flux-system annotate --overwrite fluxreport/flux \
      fluxcd.controlplane.io/reconcile=enabled

Signed-off-by: Stefan Prodan <[email protected]>
Signed-off-by: Stefan Prodan <[email protected]>
@stefanprodan stefanprodan added enhancement New feature or request area/api API related issues and pull requests labels Jun 20, 2024
Signed-off-by: Stefan Prodan <[email protected]>
@stefanprodan stefanprodan requested a review from souleb June 21, 2024 08:51
api/v1/fluxreport_types.go Show resolved Hide resolved
internal/reporter/reporter.go Show resolved Hide resolved
Copy link
Contributor

@souleb souleb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Signed-off-by: Stefan Prodan <[email protected]>
@stefanprodan stefanprodan merged commit 7fe2562 into main Jun 21, 2024
2 checks passed
@stefanprodan stefanprodan deleted the flux-report branch June 21, 2024 20:27
@stefanprodan stefanprodan added the area/observability Reporting, metrics, logs and events related issues and pull requests label Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api API related issues and pull requests area/observability Reporting, metrics, logs and events related issues and pull requests enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants