Alisson Machado

Posts

My FluxCD Notes

20 de out. de 2025

Install flux CLI

brew install fluxcd/tap/flux

Check the Kubernetes cluster

flux check --pre

Install flux on the Cluster

flux bootstrap github \
--owner=Cultura-do-Caractere \
 --repository=Youtube \
 --branch=main \
--path=./video7/cluster \
--personal

Clone the git repository

git clone https://github.com/$GITHUB_USER/fleet-infra
cd fleet-infra

Add go-app repository to Flux 

flux create source git youtube \
  --url=https://github.com/Cultura-Do-Caractere/Youtube \
  --branch=master \
  --interval=1m \
  --export > ./clusters/my-cluster/go-app.yaml

Checking image controller automaton

flux check --components-extra=image-reflector-controller,image-automation-controller

Adding new components

flux bootstrap github \
  --owner=Cultura-do-Caractere \
  --repository=Youtube \
  --branch=main \
  --path=./video7/cluster \
  --read-write-key \
  --personal --components-extra image-reflector-controller,image-automation-controller

Create Kustomize for Go-App

flux create kustomization go-app \
  --target-namespace=default \
  --source=youtube \
  --path="./kustomize" \
  --prune=true \
  --wait=true \
  --interval=30m \
  --retry-interval=2m \
  --health-check-timeout=3m \
  --export > ./video7/cluster/environments/dev/go-app/test.yaml
  --target-namespace=default \
  --source=podinfo \
  --path="./kustomize" \
  --retry-interval=2m 

Watch Flux sync the application 

flux get kustomizations --watch

Creating a secret

flux create secret git image-update \
    --url=ssh://git@github.com/Cultura-do-Caractere/Youtube \
    --ssh-key-algorithm=ecdsa \
    --ssh-ecdsa-curve=p521

Freezing Deploy

flux suspend kustomization go-app

Deleting Kustomization

flux delete kustomization go-app2

Force reconcile

flux reconcile kustomization flux-system

Getting Tree of objects

flux tree kustomization go-app

Forcing reconciliation:

flux reconcile kustomization flux-system --with-source

Running for specific kustomizaretion

flux reconcile kustomization <name> -n <namespace> --with-source

Verify last image scan

kubectl describe imagerepository podinfo

Add secret for a Docker Registry

kubectl create secret docker-registry ghcr \
  --namespace=flux-system \
  --docker-server=ghcr.io \
  --docker-username=AlissonMMenezes \
  --docker-password="your-password-here"

Scan last image

flux get image repository blog-alissonmachado-repo -n blog-alissonmachado --kubeconfig=/etc/rancher/k3s/k3s.yaml

Scanning the image manually

flux reconcile image repository my-app --namespace=flux-system