How-to guide / Policy, CI, and compliance
Generate PR-review Markdown from kix plan
These docs describe Kix's main branch, which can include changes not yet released. Read the docs for the latest release.
Use Markdown output when a CI job will post the result of
kix plan --read-only on a pull request. Kix formats the package and resource
changes for a Markdown renderer.
This guide assumes the job can reach the target Kubernetes cluster with
read-only credentials. For an offline comparison, run kix diff against a
reliable snapshot or previous build instead. It takes the same --output markdown flag and exits the same way.
Write the Markdown file
Section titled “Write the Markdown file”Run the read-only plan against the target cluster:
❱ kix plan how-to-application --read-only --output markdown Show outputHide output · 31 lines
Connecting to context kind-kix-docs (https://127.0.0.1:40563)...
⠁ Fetching live cluster state... Discovering API resources...
Fetching managed resources (62 resource types)...
Fetched 15 resources across 62 resource types
### kix plan --read-only
**Plan:** 1 updated, 0 added, 0 removed, 3 unchanged
**Resources:** 1 changed in content, 4 tracking annotation only (no spec change or restart)
#### Changed packages
<details>
<summary><code>how-to-app/production</code> 1.0.0 (1 changed, 4 tracking annotation only)</summary>
**Modified resources:**
- `ConfigMap/production@how-to-app` (1 diffs)
**Tracking annotation only (dependency changed, no spec change or restart):**
- `Deployment.apps/production@how-to-app`
- `Job.batch/production-health@how-to-app`
- `PackageInstance.kix.run/production@how-to-app`
- `Service/production@how-to-app`
</details>
**Deployment record:** `how-to-application-6n94gibgl7zv` → `how-to-application-2hrvz7i1aj05`
> Made by a read-only comparison with the cluster. Not checked: admission webhooks, admission policies, field ownership conflicts, and invalid objects; `kix plan` checks them.
(exit code: 2) Redirect it into the file the job will publish:
❱ kix plan how-to-application --read-only --output markdown > kix-plan.md The file contains GitHub-flavored Markdown suitable for a pull request comment or job summary. Publish it with the integration used by your CI provider.
Preserve the exit status
Section titled “Preserve the exit status”kix plan --read-only exits with 2 when it finds changes. Many shells running in CI
stop immediately on any non-zero status, which would prevent the Markdown
from being published. Capture the status, publish the file, then decide
whether differences should fail the job:
1set +e2kix plan production --read-only --output markdown > kix-plan.md3plan_status=$?4set -e5
6if [ "$plan_status" -ne 0 ] && [ "$plan_status" -ne 2 ]; then7 exit "$plan_status"8fi9
10# Publish kix-plan.md here.11exit "$plan_status"The three outcomes are:
| Exit code | Meaning | Suggested CI handling |
|---|---|---|
0 | No differences | Publish or replace the previous comment, then pass |
2 | Differences found | Publish the review, then fail if approval is required |
1 | Evaluation, cluster access, or another command error | Report the command failure |
If expected changes should not fail the pull request, exit 0 after publishing
when plan_status is 2. Keep genuine command errors as failures.