This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a local development environment for the Flux Operator using Docker and Kubernetes KIND. It demonstrates GitOps-style continuous delivery using OCI artifacts stored in a local registry instead of Git repositories.
make up- Create KIND cluster, local registry, install Flux Operator, and deploy infrastructure and appsmake down- Tear down the entire environment (deletes cluster and registry)make sync- Push local manifest changes to registry and reconcile with clustermake tools- Install all required tools via Homebrew (macOS only)
flux-operator -n flux-system tree ks flux-system- List all deployed resourcesflux tree kustomization apps-sync- View application resources treeflux reconcile kustomization infra-sync --with-source- Force reconcile infrastructureflux reconcile kustomization apps-sync --with-source- Force reconcile applications
- Local registry runs on
localhost:5050(external) andflux-registry:5000(internal to cluster) - Manifests are packaged as OCI artifacts and pushed to registry before deployment
-
Cluster Sync Layer (
kubernetes/clusters/local/)- Entry point for the cluster configuration
- Defines
ResourceSetInputProviderfor registry configuration - Creates two main
ResourceSetobjects:infraandapps - Sets up namespaces and RBAC (platform-team, dev-team service accounts)
-
Infrastructure Layer (
kubernetes/infra/)- Platform-level components managed by
platform-team - Installed in order with dependencies: metrics-server → cert-manager → cluster-issuers
- Uses
dependsOnwithreadyExprfor proper ordering
- Platform-level components managed by
-
Application Layer (
kubernetes/apps/)- User workloads managed by
dev-team - Demo apps: podinfo (web app with Redis cache backend)
- Apps depend on infrastructure being ready first
- User workloads managed by
This repo uses the Flux Operator's ResourceSet and ResourceSetInputProvider APIs extensively:
ResourceSetInputProvider: Provides dynamic inputs to ResourceSets
OCIArtifactTagtype - fetches container image tags (e.g., latest Redis Alpine version)Statictype - provides static configuration values (e.g., registry URL)- Can define schedules (cron) for checking updates
ResourceSet: Groups related Kubernetes resources with templating
- Uses Go template syntax with
<< >>delimiters (e.g.,<< inputs.tag >>) commonMetadata- applies labels to all resourcesdependsOn- declares dependencies on other resources with readiness checkswait- waits for all resources to become ready before reconciliation completesserviceAccountName- specifies which service account reconciles the ResourceSet
- Local manifests organized in
kubernetes/directory flux push artifactpackages directories as OCI artifacts- Artifacts pushed to local registry with
localtag - Flux Operator pulls artifacts and applies them to cluster
- Changes detected via
flux diff artifactbefore pushing
Three OCI artifacts:
flux-cluster-sync:local- fromkubernetes/clusters/local/flux-infra-sync:local- fromkubernetes/infra/flux-apps-sync:local- fromkubernetes/apps/
All workloads in this repo follow security best practices:
Pod Security Context:
runAsNonRoot: truerunAsUser: <appropriate-uid>(999 for Redis, 65534 for podinfo)fsGroup: <appropriate-gid>(1000 for Redis Alpine, 65534 for podinfo)seccompProfile.type: RuntimeDefault
Container Security Context:
allowPrivilegeEscalation: falsereadOnlyRootFilesystem: truerunAsNonRoot: truecapabilities.drop: [ALL]
Service Accounts:
- Every deployment has its own ServiceAccount
- ResourceSets specify
serviceAccountNamefor RBAC isolation
- Edit files in
kubernetes/apps/orkubernetes/infra/ - Run
make syncto push to registry and reconcile - Flux automatically detects changes and applies them
- Use
flux tree kustomization <name>to verify deployment
Follow the pattern in kubernetes/apps/podinfo.yaml:
- Create
ResourceSetInputProviderfor dynamic inputs (e.g., latest container tag) - Create
ResourceSetwith:inputsFromreferencing the providercommonMetadata.labelsfor consistent labelingdependsOnif app depends on other resources- Resources array with ServiceAccount, Deployment, Service, etc.
- Add security contexts at pod and container level
- Use templating for dynamic values:
<< inputs.tag >>,<< inputs.provider.namespace >>
- Use
app.kubernetes.io/namefor workload labels (notapp) - ResourceSets are labeled with
toolkit.fluxcd.io/tenant(platform-team or dev-team)
Makefile- Primary interface for all operationsscripts/kind-up.sh- Creates KIND cluster with registryscripts/flux-up.sh- Installs Flux Operator and instancescripts/flux-push.sh- Packages and pushes manifests as OCI artifactsscripts/flux-sync.sh- Forces reconciliation of all Kustomizationskubernetes/clusters/local/registry.yaml- Registry configuration providerkubernetes/clusters/local/infra.yaml- Infrastructure sync setupkubernetes/clusters/local/apps.yaml- Applications sync setup
The repository includes GitHub Actions workflow (.github/workflows/test.yaml) that validates the setup.