Ankra GitOps
With GitOps enabled, a cluster's stacks are stored in a Git repository and synced to the cluster by the Ankra engine (not Argo CD). Git becomes the single source of truth; changes flow through commits and pull requests, not manual edits.
Recommended path
- Golden path: GitOps as the source of truth - see
ankra-platform-principles. One platform repository for the whole estate (hub and spokes), each cluster in its own directory. - First: wire the repository when the cluster is created (
--gitops-*flags,ankra-cloud-clusters/ankra-managed-kubernetes); for an existing cluster,spec.git_repositoryin its ImportCluster (ankra-import-cluster). - Then: every change is a pull request -
ankra cluster validate,ankra cluster draftfor review, merge, let the engine reconcile. Variables over hard-coding and pinned chart versions (ankra-stacks-addons), secrets sealed with SOPS (ankra-sops-secrets). - Avoid: plaintext secrets in Git, editing the same resource in the portal and in Git at once (that is a conflict that pauses sync), and
kubectl/helmchanges the next sync will undo.
Connect a repo
In the ImportCluster spec:
spec:
git_repository:
provider: github # github (default) or bitbucket_cloud
credential_name: my-git-credential
repository: my-org/my-gitops-repo # Bitbucket Cloud: workspace/repo-slug
branch: main # must already exist; Ankra does not create branches
The credential_name references a Git credential stored in Ankra (least-privilege deploy token /
app install); ankra credentials repositories <name> shows what it can actually reach.
When Ankra builds the cluster, skip the retrofit entirely: provider create commands (Hetzner,
DigitalOcean, OVH, UpCloud, AWS, Ankra Cloud) and ankra cluster managed create take
--gitops-repository, --gitops-credential-name and --gitops-branch (pass the branch - the
server default is master), and the generated stacks land in the repo as a commit from day one.
Connecting a repository to a cluster that already has state pushes that state first, as a commit
named Connect GitOps repository, then starts syncing. Connect an empty repository or one Ankra
has written to before.
Changing git_repository on a connected cluster repoints it: Ankra writes the current state to
the new source, then syncs from it, and anything that later leaves that source is pruned (PVCs
included). ankra cluster apply refuses it without --allow-repoint (and
--allow-repoint-destroying-data when the cluster holds PersistentVolumeClaims).
ankra cluster gitops status [cluster] # repository, branch, last synced commit, observed_source, sync errors
source_mismatch: true means the last sync read a different repository than the one configured.
Layout
What Ankra writes - one directory per cluster, so the whole estate shares one repository:
platform-gitops/
clusters/
infrastructure-<short-id>/
infrastructure.yaml # the ImportCluster definition
.ankra-owned.json # what Ankra last wrote - never edit or delete
.sops.yaml # the AGE rule for this directory
stacks/
monitoring/
add-ons/kube-prometheus-stack/values.yaml
manifests/monitoring-namespace.yaml
production-<short-id>/
development-<short-id>/
Edit these files and push; Ankra applies the change. Sync is two-way: portal, CLI, API and Ankra AI
changes are committed back (authored by ankra-platform[bot] or Ankra Reconciler).
.ankra-owned.json is the overwrite and deletion boundary - Ankra keeps a file you edited instead
of overwriting it, and prunes only files it rendered. Deleting it switches that boundary off; if
it is gone, restore it from history.
A layout you write by hand points at files with include paths, which the sync loads:
stacks:
- name: platform
manifests:
- include: manifests/ # every YAML file in the folder
addons:
- include: addons/ingress.yaml # or one file
include is read when Ankra syncs from Git; ankra cluster apply -f does not resolve it, so a
file applied from the terminal uses from_file entries instead.
Workflow
- Branch from the synced branch, edit the relevant cluster YAML / values / manifests.
ankra cluster validate -f <file>(andankra cluster draft -f <file>for a reviewable draft on a cluster you are not ready to change).- Open a pull request; review the diff as "what will deploy".
- Merge - the Ankra engine reconciles the change onto the cluster.
- Confirm with
ankra cluster gitops statusandankra cluster operations list.
When Git and the platform both change
A resource changed in Git and on the platform since they last agreed is a conflict, and it
pauses the whole cluster's sync until decided. Nothing picks a side on its own:
ankra cluster gitops conflicts list [cluster]
ankra cluster gitops conflicts resolve <resource-key> --keep git|cluster
ankra cluster gitops conflicts resolve --all --keep git --yes
--keep git overwrites the platform version; --keep cluster pushes the platform version over
Git. If Git is the authority for a cluster, change it only through Git.
A file in the repository that Ankra did not write (a cluster file edited by hand) is a **preserved
path**: Ankra keeps Git's version, pauses nothing, and its own later changes to that file do not
reach Git until someone decides. ankra cluster gitops status counts them; conflicts does not
list them. Read the difference before deciding:
ankra cluster gitops preserved list [cluster]
ankra cluster gitops preserved show <path>
ankra cluster gitops preserved resolve <path> --keep git|ankra
ankra cluster gitops preserved resolve <path> --withdraw
--keep git imports Git's version and the cluster changes to match it: whatever only Ankra's
version declares (stacks, add-ons, newer chart versions) is removed or rolled back. --keep ankra
writes Ankra's version into Git over the hand edit; it is refused for SOPS-encrypted files.
resolve prints what the choice discards and asks; pass --yes only after reading it.
Rules
- Git is the source of truth. Do not hand-edit cluster state out of band; change the repo and let it sync.
- Protect the synced branch. Require PR review; treat merges as deploys.
- Encrypt secrets before commit. Never commit plaintext Secrets — use SOPS (
ankra-sops-secrets). - Pin versions. Exact chart versions and immutable image tags so a commit fully determines what runs.
- Never rename a manifest that owns a namespace or volumes - a rename is a delete plus a create.
- Small, reviewable commits. One logical change per PR; the diff should read as "what will deploy".
Terraform can manage the same clusters (ankra-terraform), but pick one owner per object - Terraform or the GitOps repository, not both.
Related skills
ankra-import-clusterfor thecluster.yamlschema.ankra-stacks-addonsfor stack design, variables and parents.ankra-sops-secretsfor encrypting Git-stored secrets.ankra-cicdfor pipelines that commit image-tag bumps into this repo.ankra-stack-profileswhen the same stack must run on many clusters.