Skip to main content
Your CI already has the schedule, the secrets and the logs. What it lacks is an answer to “what will this change do to the live cluster?” or “why did that deploy fail?”. The Ankra CLI gives a CI job two commands for that: ankra chat asks Ankra’s AI a question with your clusters as context and prints the answer, and ankra cluster apply --wait applies a cluster definition and waits for the result. This page shows one working job for each of three uses.

Prerequisites

  • A CI system that can run a shell step. The examples use GitHub Actions; the commands are the same anywhere.
  • A service token stored as the CI secret ANKRA_API_TOKEN, with the narrowest role the job needs - see Keep CI jobs read-only.
  • The CLI installed in the job:
ankra chat prints the answer on standard output and the conversation ID on standard error, so redirecting standard output captures only the answer. To parse the answer, the tools the AI ran and any change it proposed, add -o json - see Parse the answer as JSON.

Comment a review of a cluster change on the pull request

When a pull request changes a cluster definition, pass the diff to ankra chat and post the answer as a comment. Ankra’s AI compares the change with the live cluster.
Replace cluster.yaml with the path of your cluster definition and my-cluster with the cluster’s name.

Explain a failed deploy in Slack

After a merge, apply the cluster definition and wait for Ankra to accept it. If the apply fails, ask why and post the answer to Slack, so the channel gets a cause instead of a red cross.
ankra cluster apply --wait exits with code 5 when --timeout expires, so you can treat a slow apply differently from a hard failure. --wait covers the configuration write only: add-on deploys are dispatched afterwards, so check them with ankra cluster operations list before calling a rollout healthy. The CLI’s other exit codes let a job treat 3 (not found) as success for idempotent steps and re-authenticate on 6.

Post a scheduled health check

Run every 30 minutes, stay silent while everything is healthy, and post to Slack only when something is degraded.
Without --cluster, ankra chat answers across the whole organisation.

Parse the answer as JSON

With -o json (or -o yaml), ankra chat "<question>" prints one document on standard output when the turn ends, instead of streaming the answer. Status lines and notices go to standard error, so standard output is only the document. The health check above, with a parsed result:
A turn that starts and then fails still prints the document, with error set, and exits non-zero. When the platform refuses to start the turn, nothing is printed on standard output and the command exits with that error’s exit code (6 for a rejected token, 3 for an unknown cluster). -o works for a one-shot question only, not for interactive chat.

GitLab CI and other runners

The commands are the same in any CI. In GitLab CI, run the review job on rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" and diff against $CI_MERGE_REQUEST_DIFF_BASE_SHA, and run the health check from a scheduled pipeline with rules: - if: $CI_PIPELINE_SOURCE == "schedule".

Keep CI jobs read-only

  • The review and health check jobs only read. Give them a service token with the viewer role, which includes ask-mode AI. Token --scopes only choose MCP access (mcp:read, mcp:write), so the role is what limits a CLI token.
  • Only the deploy job writes. Give it a separate service token with a role that can deploy Stacks, such as member.
  • Run ankra chat with --mode ask: ask mode investigates and may make safe creations, but does not change what is already running. Never pass --mode agent in CI; make changes through ankra cluster apply and your GitOps repository.