Ankra sops secrets

From ankraio/ankra-cli · View interactive version

Ankra sops secrets is an AI agent skill from the GitHub repository ankraio/ankra-cli. Encrypt Kubernetes Secrets and sensitive addon values with SOPS and AGE so they can live in an Ankra GitOps repo, using `ankra cluster encrypt`/`decrypt` in cluster mode or file mode, glob key patterns that keep covering keys added later, `--all-data` for a whole Secret, and `encrypted_paths` so Ank

How to use this skill

Skill file

Ankra secrets with SOPS

Recommended path

values file lives in the GitOps repository sealed with SOPS, encrypted_paths declares it, and

ankra cluster apply plus the Ankra engine deploy it.

is the source of truth, or in cluster mode for a stack that already runs.

ankra-gitops; a secret only one application reads belongs in ankra application env-secrets.

sets up): ankra secrets create <name> --generate, then put the printed ${SECRET_SLOT:<id>}

sentinel where the value belongs, at a key encrypted_paths declares. The value never passes

through a terminal, a file you commit, or a model. See "Secret slots" below.

host) in encrypted_paths, decrypted output in a transcript, and a secret value typed into a

command line or a chat.

Never commit a plaintext Secret. Ankra integrates SOPS (with AGE keys) so sensitive manifest and

addon values are ciphertext in Git and decrypted only at deploy time — while the surrounding YAML

stays readable, so diffs remain reviewable.

Concepts

encrypted. An encrypted value with no declared path deploys as ciphertext — this is the most

common SOPS mistake in Ankra.

ankra cluster sops-config          # the organisation's SOPS configuration and public key

Two modes, and when to use which

Both encrypt and decrypt work either against the live cluster or against a local file.

| Mode | What it does | When |

|------|--------------|------|

| Cluster (default) | Fetch from the live cluster, encrypt, push back via the partial-stack PATCH. The owning stack is resolved automatically. | The stack already exists on a cluster |

| File (-f cluster.yaml) | Rewrite the from_file the local cluster.yaml references, in place, and add the key to encrypted_paths in the file | GitOps, where the source of truth is on disk |

Encrypting

ankra cluster encrypt manifest db-secret --key password
ankra cluster encrypt manifest db-secret --key password --cluster prod
ankra cluster encrypt manifest db-secret --key password --key api-token
ankra cluster encrypt manifest db-secret --all-data --cluster prod
ankra cluster encrypt manifest db-secret --key 'glob:stringData.DB_*' --cluster prod
ankra cluster encrypt manifest db-secret --key password -f cluster.yaml

ankra cluster encrypt addon --name my-app --key apiKey
ankra cluster encrypt addon --name my-app --key apiKey --cluster prod --stack apps   # --stack when the name is in several stacks
ankra cluster encrypt addon --name my-app --key 'glob:*Password' -f cluster.yaml

Key semantics worth knowing before you write a --key:

A dotted --key is normalised to its last segment. SOPS matches key names anywhere in the

document.

Secret) is kept literally.

re-encrypt*, so keys added afterwards are covered automatically. Only * is a wildcard;

everything else is literal. A pattern matching nothing fails, the same as a misspelled key.

values already encrypted. The manifest must be a Secret; --all-data and --key are mutually

exclusive.

--key, in both modes, so a file decrypted for inspection is sealed whole on the next encrypt.

What an entry actually matches

An entry names a key, not a location. Ankra compiles the entries into a SOPS encrypted_regex

of key names, and SOPS applies it at every depth: auth.password seals every password key in

the file. That is why a key added under a new section is covered, and why a structural name is a

trap: never declare key, name, path, value, type, host, port or operator, bare

or as the last segment (tls.key, metadata.name). It seals the chart's own fields too, and the

render or sync then fails. Give the secret a distinctive name (smtpPassword) or put it in its own

Secret manifest. ankra cluster validate reports over-broad entries as

encrypted_paths_over_match.

Changing a secret value without committing plaintext

This is the pattern that matters most, and the obvious route gets it wrong.

# Right: the new value and its encryption land in ONE commit
ankra cluster encrypt manifest db-secret --key password \
  --set 'data.password=bmV3LXNlY3JldA==' --cluster prod

In cluster mode --set applies the value edit in memory before encrypting, so the plaintext

never reaches Git history. It also replaces a value that is already sealed, which is how a sealed

credential is rotated in place (escape a key that starts with a dot:

--set 'data.\.dockerconfigjson=<base64>').

# Wrong: this commits the plaintext value first, and it stays in history forever
ankra cluster manifests upgrade db-secret --set 'data.password=...'
ankra cluster encrypt manifest db-secret --key password

If plaintext has already been committed, treat the value as compromised: rotate it at the source,

then encrypt the new one. Rewriting Git history is not a fix.

Decrypting

ankra cluster decrypt manifest db-secret
ankra cluster decrypt manifest db-secret --cluster prod
ankra cluster decrypt manifest db-secret -f cluster.yaml
ankra cluster decrypt addon --name my-app --cluster prod

Decryption prints to stdout. Use it to verify shape — that the right keys are encrypted, that a

value is present — not to copy values around. Never paste decrypted output into a pull request, a

commit message, an issue, a chat message, or a CI log.

Declaring it in the stack

manifests:
  - name: db-secret
    from_file: "manifests/db-secret.yaml"
    encrypted_paths:
      - data.password
      - data.username
      - "glob:stringData.DB_*"
addons:
  - name: my-app
    chart_name: my-app
    chart_version: 1.4.2
    registry_name: example-charts
    registry_url: https://charts.example.com
    namespace: app
    configuration:
      from_file: "values/my-app.yaml"
      encrypted_paths:
        - secrets.apiKey

A glob entry is recorded in encrypted_paths as written (glob:stringData.DB_*), which is the

form the platform re-expands into the SOPS encrypted_regex on every push. ankra cluster encrypt

maintains these entries for you in file mode; if you hand-edit the YAML, keep them in sync.

Verify what the platform actually stored:

ankra cluster stacks list <stack> -o json     # echoes each resource's encrypted_paths

Empty and absent are different. Over the API, omitting encrypted_paths on an update keeps

the stored declaration, while encrypted_paths: [] clears it and the next platform write renders

the file as plain content. ankra cluster apply drops an empty list, so [] in a cluster YAML

keeps what is stored; a sealed from_file with no stored declaration is refused. In a repository

Ankra syncs, the declaration is derived from the sealed file's sops metadata.

Who decrypts. On the native engine (the default) the Ankra agent fetches the organisation's

private key at deploy time and decrypts inside the cluster; nothing is installed beforehand.

Secret slots: values that never pass through you

ankra secrets manages the organisation's secret slots. A slot holds one value in Ankra's vault;

the stack carries only its sentinel, ${SECRET_SLOT:<id>}, and Ankra substitutes the value only

when it SOPS-seals the file for delivery. The cluster YAML you write, review and commit holds the

sentinel, never the value, so this is the home for a value that must not live in Git even

encrypted by hand, and for any secret an AI agent creates for you.

ankra secrets create db-password --generate            # Ankra creates the value; prints the sentinel
SENTINEL="$(ankra secrets create db-password --generate)"   # stdout is the sentinel alone
printf '%s' "$STRIPE_KEY" | ankra secrets create stripe-key  # a value you have, on stdin
ankra secrets create tls-key --from-file ./tls.key     # a file, byte for byte
ankra secrets list                                     # names, ids, who uses each, last read; never values
ankra secrets set stripe-key --from-file ./new.key     # replace in place; the sentinel stays valid
ankra secrets rotate db-password --generate            # a new generated value, in place
ankra secrets delete stripe-key                        # refused while anything references it

Use the sentinel at a key the resource seals:

addons:
  - name: grafana
    configuration:
      from_file: "values/grafana.yaml"     # adminPassword: ${SECRET_SLOT:0b6f2c1e-...}
      encrypted_paths:
        - adminPassword

the process list keep argv. Use --generate, stdin or --from-file.

not declare is refused at push time, and an organisation without SOPS configured refuses the

save. Run ankra cluster sops-config first.

--ttl up to a week). A slot with a --ttl is kept past it for as long as a deployed resource

references its sentinel; check ankra secrets list (EXPIRES never or never (in use)).

references the sentinel changes; Ankra re-delivers the resources that use it.

named; remove the sentinel from them first. There is no force.

Where a secret should live

SOPS in Git is one of three homes, and picking the wrong one is a common mistake:

| Value | Home |

|-------|------|

| A Secret or addon value a stack deploys | SOPS-encrypted in the GitOps repo, encrypted_paths declared |

| A value nobody should see, type or commit (generated passwords, tokens an agent sets up) | ankra secrets create --generate; the stack carries the sentinel at a declared encrypted_paths key |

| A secret only one application needs | ankra application env-secrets set (then apply) |

| A non-secret that varies per environment | A cluster / organisation / stack variable |

See ankra-app-integrations for the full split.

Traps

built from a sealed stack, check each sealed resource still declares encrypted_paths, and bind

secrets at launch with --set-file/--set-env (see ankra-stack-profiles).

glob: pattern when the key set will grow.

correctly does not make it reachable from elsewhere.

Organisation key rotation is not self-service: every sealed file must be re-encrypted first.

Rules

only its sentinel goes in the stack.

Related skills

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.