GitOps over OCI: Flux and Argo CD deploying from ConfigHub
This page is for a platform team that runs Flux or Argo CD, and whose agents now propose changes to what those tools deploy. It shows how to make the cluster deploy only changes a named person has approved, with the reason for each value kept. To move an app that Argo CD or Flux already deploys from your Git, and hand it back, see an app that Argo CD or Flux deploys.
The walkthroughs a Kustomize app that Argo CD deploys and a Kustomize app that Flux deploys do this on a kind cluster with a starter, with every command and what it prints.
What "deploying from the hub over OCI" means
Today, your cluster's Flux or Argo CD deploys whatever reaches the Git branch it watches. A person has to read every agent's diff to know whether it should ship. Nothing in Git says why a value is what it is.
With this setup, your cluster's Flux or Argo CD pulls the approved configuration from ConfigHub instead of from Git:
- An agent proposes a change in ConfigHub. The change waits.
- A person you name approves it.
- ConfigHub publishes the approved configuration as a release.
- Flux or Argo CD pulls the release from ConfigHub and applies it.
A change someone makes by hand on the cluster is put back. Going back to an earlier value is an approved change like any other. For every release, ConfigHub shows what the cluster reported about it.
You can keep writing and reviewing changes in Git. What the cluster runs is what was approved in ConfigHub. Flux calls this Gitless GitOps.
From Git to the hub, one step at a time, and back
You do not have to move delivery off Git to get anything on this page. Each step below is reversible, and you can stop at any of them.
| Step | What changes | What you get | To go back |
|---|---|---|---|
| 1. The Claude plugin | the record in agent sessions; the review on pull requests | every configuration value a pull request changes, per cluster, and why; the next agent told before it undoes an earlier change; Git still delivers | uninstall the Claude plugin |
| 2. A hub beside Git | cub mini copy --from-git takes the repository's rendered configuration into a hub, which keeps each value's reason and protects the ones you choose; the hub's approval appears on each pull request as a status, and your branch rule requires that status | approvals of exact values; values kept through a chart's next version; Git still delivers. The branch rule requiring the status is what makes the approval one that Git cannot bypass | stop the hub; Git is untouched |
| 3. The hub as the source for one app | that app's Flux source or Argo CD Application is pointed at the hub's OCI gateway instead of the Git path; Git keeps everything else | the hub's approval is the only way a change reaches that app; an agent's kubectl change is set back by the next sync, and the hub says what differed | cub mini copy --to-dir writes plain files and a CHANGES.md; commit them, point the source back at Git, stop the hub |
| 4. The hub as the source for everything | the clusters deploy from the hub; Git holds rendered files written back for people to read and diff | one source, with Git still legible | as step 3, app by app |
Steps 1 to 3 have run; the rest of this page is step 3. Step 4's write-back to Git is not built. Nothing on this page is a migration: a GitOps team meets the hub as the source for one app, beside its Git, and goes back by committing files.
The words on this page, such as hub, base and change order, are explained in the glossary.
What you need
- The local hub (install it).
- Docker,
kind(Kubernetes in Docker) andkubectl. - For Flux, the
fluxCLI.
The steps below set this up on the local hub and a local kind cluster. Then they show the four things a GitOps team asks about: a change that waits for a person's approval, self-heal, going back, and the cluster's status in ConfigHub.
The cub mini commands on this page are plain cub with the rest of the request filled in (which commands). For your own cluster with a shared hub on confighub.com, further down, the same is shown with cub alone.
The example follows Dan's platform team, which runs Flux and Argo CD with self-heal on.
Step 1: Make the cluster, with Flux and k8sbot
- Make the cluster:
cub cluster up shop --controller fluxThis makes a kind cluster named
shop, installs Flux in it, and connects it to the hub. It adds:- an
OCIRepositoryand aKustomization, which pull the cluster's apps from ConfigHub; - k8sbot.
To install Argo CD in place of Flux, use
--controller argo(With Argo CD). - an
- Point your shell at the cluster:
source ~/.confighub/clusters/shop.envThis sets
KUBECONFIG, and thecubcontext for the cluster.
On OrbStack, put gitops/docker first on your PATH for this step. Otherwise cub points the cluster at an address that does not reach a hub listening on 127.0.0.1. With Docker Desktop you do not need this.
Step 2: Deploy an app from the hub
- Make a folder for the app, with its Namespace:
mkdir api cat > api/namespace.yaml <<'EOF2' apiVersion: v1 kind: Namespace metadata: {name: shop} EOF2The Namespace belongs with the app, since Flux creates nothing it is not given.
- Add the Deployment:
cat > api/api.yaml <<'EOF2' apiVersion: apps/v1 kind: Deployment metadata: {name: api, namespace: shop} spec: replicas: 2 selector: {matchLabels: {app: api}} template: metadata: {labels: {app: api}} spec: containers: - {name: api, image: registry.k8s.io/pause:3.10} EOF2 - Put the app in the hub, as the Component
apiwith alivecopy:cub mini upload api --variant live --namespace shop --yes
Flux now runs 2 replicas of api, pulled from the hub.
This is what Flux pulls from, as cub cluster up and cub mini upload set it up:
apiVersion: source.toolkit.fluxcd.io/v1
kind: OCIRepository
metadata: {name: api-live, namespace: flux-system}
spec:
url: oci://host.docker.internal:PORT/space/api-live # the hub's OCI registry, one repository per Space
ref: {tag: latest}
secretRef: {name: confighub-oci} # the cluster's own key to the hub
interval: 10m
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata: {name: api-live, namespace: flux-system}
spec:
sourceRef: {kind: OCIRepository, name: api-live}
path: .
interval: 10m
prune: false
wait: trueStep 3: A change that waits for a person
- Require approval for the live copy, and make an agent named
bot:cub mini require-approval api --variant live --agent bot--agent botgives the agent a key of its own, in acubconfiguration of its own,~/.confighub-agent-bot. The next two commands runcubas the agent, by pointingCUB_CONFIGandCUB_CONTEXTat that configuration. - As the agent, change the base to 4 replicas:
CUB_CONFIG=~/.confighub-agent-bot CUB_CONTEXT=bot cub function set --space api-base --unit api --change-desc "Four for the sale" set-replicas 4 - As the agent, ask for the change to reach the live copy, with a change order:
CUB_CONFIG=~/.confighub-agent-bot CUB_CONTEXT=bot cub changeorder create --space api-base sale-4 --component api --change-workflow workflows/api-live-approval --description "Four for the sale"The agent's change waits. Nothing is released, and the cluster still runs 2 replicas.
- As yourself, approve the change and promote it to the live copy:
cub mini approve api-live --note "Checked: four is right for the sale"It shows the change and asks first. ConfigHub releases the change, and k8sbot asks Flux to deploy it. Shortly after, the cluster runs 4 replicas.
Step 4: Self-heal
- Change the cluster by hand:
kubectl -n shop scale deploy api --replicas=7 - Ask Flux to apply the release again now:
flux reconcile kustomization api-live -n flux-system --with-sourceFlux applies the approved release again, and the cluster is back at 4 replicas.
Without the flux reconcile, Flux does the same at its next interval, which is 10 minutes here. Argo CD, with self-heal on as cub cluster up sets it, put the approved value back by itself.
Step 5: Go back
Going back is a change like any other, so it waits for an approval too.
- Change the base back to 2 replicas:
cub function set --space api-base --unit api --change-desc "The sale is over" set-replicas 2 - Ask for it with a change order:
cub changeorder create --space api-base back-to-2 --component api --change-workflow workflows/api-live-approval --description "The sale is over" - Approve and promote it:
cub mini approve api-base/back-to-2 --note "Back to two"Shortly after, the cluster runs 2 replicas again.
cub variant demote restores the earlier revision in the hub, but it is not the way back here. Where approval is required, ConfigHub releases only what an approved change order covers. So the way back is a change order, as above.
Step 6: See what runs, in ConfigHub
$ cub release list --space api-live
NUM TAG CHANGEORDER PUBLISHED SYNC HEALTH
3 api-base/back-to-2-co-publish api-base/back-to-2 true Synced Healthy
2 api-base/sale-4-co-publish api-base/sale-4 true OutOfSync Unknown
1 release-1 true OutOfSync UnknownEach line is one release. It shows the change order that made the release, and what k8sbot last reported from the cluster. Only the release running now reads Synced. Earlier releases read OutOfSync once a later one has replaced them.
With Argo CD
cub cluster up shop --controller argo installs Argo CD in place of Flux. Each deployment is an Argo CD Application that reads the hub's OCI registry, with auto-sync and self-heal on:
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata: {name: api-live, namespace: argocd}
spec:
project: default
source:
repoURL: oci://host.docker.internal:PORT/space/api-live
targetRevision: latest
path: .
destination: {server: https://kubernetes.default.svc}
syncPolicy:
automated: {selfHeal: true, allowEmpty: true}The other steps are the same, except that step 4 needs no flux reconcile. Argo CD's UI is at the address cub cluster up prints.
With Argo CD, the approved change runs a few seconds after the promotion, and so does going back. Every release reads Synced and Healthy.
Your own cluster, with hosted ConfigHub
The same works with a cluster you already have and a shared hub on confighub.com, or a ConfigHub server of your own.
- Sign in to ConfigHub with
cub auth login, and pointkubectlat your cluster. - Connect the cluster to ConfigHub:
cub cluster attach my-clustercub cluster attachconnects the cluster your kubeconfig points at to ConfigHub. It creates no cluster. It adds:- a credential Argo CD pulls with: a token of a service account made for the cluster;
- a root Application;
- k8sbot.
An Argo CD already in the
argocdnamespace is left as it is. Otherwise Argo CD is installed. You need Argo CD v3.1 or later, foroci://sources.For Flux, run
cub cluster attach my-cluster --controller fluxinstead. A Flux already influx-systemis left as it is. - Put the app in ConfigHub, make its live copy aimed at the cluster, and publish its first release:
cub component create api cub space create api-base --component api --variant base cub unit create --space api-base namespace api/namespace.yaml cub unit create --space api-base api api/api.yaml cub variant create live api-base --target my-cluster/target cub release publish api-liveArgo CD pulls the release from
oci://oci.hub.confighub.com:443/space/api-live. - Set up the approval gate with
cubalone, as in approvals. - After the approval, promote the change and release it, by its change order:
cub variant approve api-base --change-order api-base/sale-4 --note "Checked: four is right for the sale" cub variant promote api-live --change-order api-base/sale-4 cub release publish api-live --revision ChangeOrder:api-base/sale-4
What you see with Argo CD already on the cluster, here v3.1.9:
cub cluster attachleaves that Argo CD in place.- The first release runs 2 replicas.
- Before the approval, the promotion is refused ("requires approval: … 0 of 1"), and the cluster still runs 2.
- After the approval, the cluster runs 4 within seconds of the promotion.
- A scale to 7 made by hand is put back by Argo CD within seconds.
cub release listshows the running release Synced and Healthy.
What you see with Flux already on the cluster (flux install):
cub cluster attachleaves Flux in place.- Flux pulls the release from
oci.hub.confighub.com. - A released change runs within seconds.
- A scale made by hand is put back.
To remove it:
cub cluster detach my-clusterdisconnects the cluster from ConfigHub, and leaves the cluster as it is.- Delete the Spaces
my-cluster,my-cluster-argo-apps,argobot-my-clusterandargobot-basewithcub space delete --recursive. - Delete the Component
argobotwithcub component delete. - Delete the service account
argo-my-clusterwithcub serviceaccount delete.
A change made in Git
Dan's team still reviews some changes as pull requests. The hub's copy can live in a Git repository of its own, written by the hub. A change merged there comes back into the hub, with the pull request's reason.
- Write the hub's copy to the root of a new folder. You do this once:
cub mini copy api --variant live --to-dir shop-config # once: the hub's copy, at the root of a new repository - Make the folder a Git repository:
cd shop-config && git init -b main && git add -A && git commit -m "The hub's copy" && cd .. - A pull request changes
shop-config/api-live/api.yaml, is reviewed, and is merged. - Bring the merged change into the hub:
cub mini copy --from-git shop-config --variant live --since FIRST-COMMITThe value is kept in the hub. Its reason is the commit's message, the commit, and its author. The cluster then runs it.
Replace FIRST-COMMIT with the hash of the commit made in step 2, "The hub's copy" (right after step 2, git -C shop-config log --format=%h -1 prints it). --since takes in every change committed after it. The commit taken in is recorded on the copy, so you need --since only the first time.
Each top-level folder of the repository is a Space. So the copy must be at the root of the repository, not in a subfolder.
For example, with Flux and no approval required for live, a merged change from 2 to 3 replicas is kept in the hub as "Three for the launch, reviewed in a pull request (Git, commit bb2beb3, by Dan)", and the cluster runs 3 replicas a few seconds later.
When the hub is down
What runs keeps running. The controller holds the last release it pulled.
With Flux, while the hub is stopped:
- The app keeps its 2 replicas.
- Scaled to 7 by hand, it's put back to 2 by Flux, from its last release.
- New releases wait.
- When the hub starts again, Flux fetches from it straight away.
We haven't tried this with Argo CD yet.
What k8sbot may do in your cluster
k8sbot reads, and makes one kind of write.
On the cluster cub cluster up --controller flux makes, k8sbot's service account has two ClusterRoles:
- One to get, list and watch pods and their logs, services, endpoints, configmaps, events, namespaces, nodes, volumes, and the workload, networking and Flux resources. It does not include Secrets.
- One to get, list, watch and patch Flux
OCIRepositoryobjects. Patching one is how k8sbot asks Flux to deploy.
With Argo CD, k8sbot patches an Application's refresh annotation instead, as its own README describes.
Remove the cluster
cub cluster down shop --delete-configThis deletes the cluster, and its setup in the hub.