Ankra ImportCluster
An ImportCluster manifest is the declarative entry point for onboarding an existing Kubernetes cluster (EKS, GKE, AKS, on-prem, k3s, kind, minikube) into Ankra, and the same schema Ankra reads from a cluster's GitOps repository. Apply it with ankra cluster apply -f cluster.yaml.
Recommended path
- Golden path: GitOps as the source of truth - see
ankra-platform-principles. The file lives in the platform repository withspec.git_repositoryset, is checked withvalidate, staged withdraftfor review on anything that matters, and only then applied; the Ankra engine reconciles it. - Pin every
chart_version, put per-environment values invariables, and seal secrets with SOPS (ankra-sops-secrets) - never plaintext in Git. - A cluster Ankra should build is
ankra-cloud-clusters/ankra-managed-kubernetes(managed ones import withankra cluster managed import, no YAML needed). Repository layout isankra-gitops; stack design isankra-stacks-addons. - Only connecting a cluster, with nothing to declare yet? No file is needed:
ankra cluster connect <name> [--environment production]registers it and prints the agent install command, and refuses a name another cluster already has (exit 8) instead of updating that cluster. Write the file when stacks, add-ons or a GitOps repository go in with it. - Avoid: applying straight to production without a reviewed draft, and
kubectl apply/helm installbeside the file - the next apply or sync removes what the file does not declare.
Anatomy
apiVersion: v1
kind: ImportCluster
metadata:
name: my-cluster
description: Importing my Kubernetes cluster
spec:
git_repository: # optional: enable GitOps for this cluster
provider: github # github (default) or bitbucket_cloud
credential_name: my-git-credential
repository: my-org/my-gitops-repo
branch: main
stacks:
- name: logging
description: Stack for logging
deploy_wave: 1 # optional: order whole stacks
variables: # optional: stack-scoped, highest precedence
LOG_LEVEL: info
manifests:
- name: namespace-fluent-bit
parents: []
from_file: "manifests/fluent-bit-namespace.yaml"
- name: configmap-fluent-bit
parents:
- kind: manifest
name: namespace-fluent-bit
from_file: "manifests/fluent-bit-configmap.yaml"
addons:
- name: fluent-bit
chart_name: fluent-bit
chart_version: 0.49.1 # pin exact version, especially in prod
registry_name: fluent
registry_url: https://fluent.github.io/helm-charts
namespace: fluent-bit
parents:
- kind: manifest
name: configmap-fluent-bit
configuration:
values: |-
logLevel: ${{ ankra.LOG_LEVEL }}
Field reference
spec.git_repository— connect a Git repo so stacks are stored and synced from Git (seeankra-gitops).providerisgithub(default) orbitbucket_cloud(workspace+repo_slugin place ofrepository); the branch must already exist. Changing this block on a cluster that has one repoints it and is refused without--allow-repoint(plus--allow-repoint-destroying-datawhen the cluster holds PersistentVolumeClaims). Omit for a non-GitOps import.spec.prometheus_metrics— the cluster's metrics source (endpoint, optionalcredential_name,flavor). Credentials are referenced by name, never inlined.spec.stacks[]— each stack groups relatedmanifests,addonsandapplications(deployments of Ankra applications byplatform_application_id).variables— stack-scoped map, referenced as${{ ankra.NAME }}in manifests and values; shadows cluster (ankra cluster variables) and organisation (ankra org variables) values. Quote anything that is not a plain string or integer.deploy_wave— integer>= 0; a stack in wave N deploys only after every lower wave succeeded. Stacks without one are unordered.backup— the stack's backup policy (enabled,vault,schedule,retention,selection); seeankra-backups. An omitted block never removes protection.manifests[]— raw Kubernetes YAML:from_file: "path.yaml"or inlinemanifest: |-. Optionalnamespace,encrypted_paths,force(replace on conflict) andauto_remediate(re-apply on drift). Thenameis the identity: renaming a manifest deletes everything it owned (a Namespace and its PVCs included) and creates it anew.addons[]— Helm releases. Required:chart_name,chart_version,namespace. Name the chart source withregistry_name+registry_url(withregistry_credential_namefor a private registry — seeankra-helm-registries); the olderrepository_urlis still accepted. Configure viaconfiguration.values: |-(inline) orconfiguration.from_file:,configuration.encrypted_pathsfor SOPS-sealed keys, andsettingsfor sync behaviour.agents_md/agents_md_from_file— optional per-manifest and per-addon AGENTS.md: operational learnings in plain markdown, stored as a sibling file in the GitOps repo (e.g.agents_md_from_file: "manifests/fluent-bit.AGENTS.md"). Omitting the field preserves the stored content, an explicit empty string clears it, and editing it never triggers a redeploy. Plaintext only — never put secrets in it. After any non-obvious operation (a values quirk, an upgrade pitfall, a dependency gotcha), record what you learned here so future agents working on the same addon or manifest benefit.group— optional per-manifest and per-addon organizational label within the stack (a quoted string, e.g.group: "platform services"). Purely organizational: it never triggers a redeploy. Keep whatever the exported file carries — apply prunes what the file no longer declares, so removing the key removes the resource from its group.parents— the dependency edges that control deployment order. A resource only deploys after its parents succeed. Every parent is akind+namepair — write both keys (- kind: manifest/name: <name>, orkind: addon). The shorthand- manifest: <name>does not work: it parses to an empty parent and the edge is silently dropped, while both local and server-side validation still pass. Verify what was stored withankra cluster stacks list <stack> -o json.
spec.helm_registries, spec.log_source and - include: <path> entries are read by the GitOps sync when Ankra reads the file from the repository; ankra cluster apply -f does not send them (an include entry is refused for having no name). Use them only in a Git-synced file.
Workflow
- Create namespaces as manifests first; make dependent addons/configmaps list that namespace manifest in
parents. - Pin every addon's
chart_versionto an exact version. - Keep secret material out of plaintext — encrypt with SOPS and mark
encrypted_paths(seeankra-sops-secrets). - Validate, stage, apply:
ankra cluster apply -f cluster.yaml --dry-run # local checks only, no API call
ankra cluster validate -f cluster.yaml [--cluster prod] [--strict-secrets] # server-side, changes nothing
ankra cluster draft -f cluster.yaml # stage every stack as a reviewable draft
ankra cluster stacks deploy-draft <stack> # deploy a reviewed draft
ankra cluster apply -f cluster.yaml [--cluster prod] # or apply directly
ankra cluster operations list # watch the resulting add-on deploys
apply is a declarative replace per stack: what the file no longer declares is removed from
that stack. --wait waits only for the configuration write, not for the add-on deploys - follow
those with ankra cluster operations list. draft is the safe route on a cluster you are not
ready to change; --cluster targets a cluster other than metadata.name.
Terraform users can declare the same cluster and stacks with ankra_cluster (see ankra-terraform); keep one source of truth per cluster.
Rules
- Namespace manifests must come before anything deployed into that namespace, expressed via
parents. - Pin chart versions; never use floating/
latestcharts in production. - Reference files with forward-slash relative paths (
manifests/foo.yaml), resolved from the manifest's location. - Keep stacks small and focused (one concern each) rather than one giant stack.
- Never rename a manifest that owns a namespace or stateful resources without moving the data first.
Related skills
ankra-stacks-addonsfor composing stacks in depth.ankra-gitopsfor the repository layout that backsspec.git_repository.ankra-backupsfor thebackupblock,ankra-sops-secretsforencrypted_paths.ankra-clifor applying and watching operations.