Overview

In a mature GitOps environment, everything is a pull request. With human engineers, Renovate, and AI coding agents all opening them, PR volume explodes and reviewers get "YAML fatigue". That is exactly when plausible-looking manifests slip through, like a Kustomize patch that silently applies to nothing or a selector that doesn't match its own template. The old multi-task Tekton pipeline took minutes per run and kept its logic in Bash that could not be unit-tested (see the Timeline).

CI is the universal safety net. k8s-gitops-ci is an open-source, org-agnostic single Go binary. It resolves exactly what a PR changed, lints it, builds only the affected Kustomize/Helm overlays, runs Kubernetes compliance checks, and posts one unified report back on the PR. The same command runs on a laptop with no remote and no PR.

Highlights
  • Seconds, not minutes: one process, with no per-linter pods or shared PVC.
  • App-aware builds: only overlays whose Kustomize graph reaches the change are built.
  • API-server rules, offline: the cluster's own admission validation, ported to Go.
  • Org-agnostic: import it as a Go module, no forks needed.

Upcoming: presenting “Robust CI as a Safety Net” at KubeCon (Salt Lake City) with Jennifer Weir — a 30-minute tag-team session pairing GitOps philosophy with a deep dive into the Go architecture.


One Binary, Not a Pile of Pods
  • Kustomize builds run through the native Go SDK and Helm charts render through the native chart loader — no helm binary, and no kustomize binary for builds.
  • kubeconform runs as a library with its schemas embedded and pinned to an upstream commit — no CDN and no network at run time.
  • The payoff in wall clock: what used to take minutes now takes seconds.
App-Aware Overlay Detection
  • The engine finds the app root you touched and walks each overlay's actual Kustomize reference graph, building only the overlays that genuinely reference the changed piece.
  • Ghost Patch Detection: a Kustomize patch that targets nothing doesn't error — it silently does nothing. The engine flags the orphans.
  • Kustomize Fix: a dry-run of the real kustomize edit fix, with the exact fix command in the report to copy and paste.
Runtime Validation — Beyond the Schemas
  • The OpenAPI schemas kubeconform validates against carry almost no value-level constraints: the schema for metadata.name is literally "string or null", so a 400-character name passes.
  • So the Kubernetes API server's own admission validation is ported into Go, and every rule cites the upstream function it came from; task ci fails if upstream changed it.
  • Runtime findings are always blocking and never exemptable: the cluster itself would reject those manifests.
Security by Default
  • PR-triggered CI is not a security boundary. On a pull request, test.sh is read from the trusted target branch, not from the PR; a /hook-test comment opts a PR in.
  • Transparent exemptions: annotations sit next to the field they excuse and show up in the PR diff. A malformed exemption parses to zero exemptions plus a blocking error, so a typo can never silently over-exempt.
  • The hard line: CEL rules, broken JSON, missing-registry image FQDNs, and every runtime check are not exemptable. You can turn a check off — you can't lie about a finding.
Org-Agnostic by Design
  • A generic engine with no org names, cluster names, or company domains in the code. Organizations import it as a Go module and compile a thin wrapper binary — no forks required.
  • Org-specific behavior is injected at startup through a provider.Providers seam.
  • Every step has a stable ID that can be turned on or off with --enable-checks / --disable-checks.
One Unified Report
  • Instead of spamming the PR, the engine updates a single collapsible markdown comment, and every section records its status so a linter never silently disappears.
  • Applied exemptions render in an audit table, so new drift can't hide behind an old waiver.
  • The comment ends with a ready-to-copy CLI command so any engineer or AI agent can reproduce the run locally.

Technology Stack

  • Language: Go.
  • In-process: Kustomize SDK, Helm chart loader, kubeconform (embedded schemas), CEL.
  • External tools: shellcheck, golangci-lint, markdownlint, prettier, kyverno, kustomize (for edit fix).
  • Forges: GitHub and GitLab.
  • Delivery: Tekton Pipelines-as-Code for the repo's own CI, GitHub Actions for multi-arch images, GoReleaser for releases.
  • Packaging: Go module, release binaries, and a multi-arch UBI 10 Minimal container image on GHCR.
  • Testing: table-driven suites with false-positive guards, a non-blocking live-PR replay, and upstream-citation verification.

Pipeline Flow

The binary runs a fixed sequence of phases. Cheap, decisive gates run first, independent work fans out across goroutines (bounded by CPU count), and everything funnels into one report. The repo's own CI is deliberately tiny — one Pipelines-as-Code PipelineRun with two parallel tasks — because the heavy lifting lives in the binary, where it is testable. The lint task runs the tool against the repo itself.

  1. PR Validation (forge API only, cheap): PR title convention, unsigned commits, PR checklist.
  2. Changeset Resolution — determine exactly which files this PR touches.
  3. Large File Check and YAML Syntax — two sequential gates, since everything downstream assumes parseable files.
  4. Linting — fanned out: markdownlint, prettier, golangci-lint, shellcheck (which also lints Bash embedded in Tekton task scripts and container commands), and raw-manifest kubeconform.
  5. Static Checks — fanned out: config sort order, starting-CSV sanity, and the scaffold README status table.
  6. Build YAML — scaffold validation, then the affected overlay set (app-aware, not a bare path match) is rendered through the native Kustomize/Helm engines (with AVP where configured), followed by Kustomize Fix and Ghost Patch Detection.
  7. Post-Build Validation — against the rendered output: kubeconform, CEL, runtime validation, NAD validation, the resource-compliance registry, and Kyverno (opt-in). Every finding is classified as blocking (direct) or warning-only (external).
  8. Unified Report — one PR comment (or console output) assembled from every phase.

The Dual Pass: Raw vs. Rendered

Some checks must run against the raw committed file — a vault-plugin placeholder like <vault:secret> is a legitimate state in git; it resolves at deploy time, not at review time. Other checks must run against the final rendered output, after Kustomize generators and patches have done their mutations. The engine runs both passes and guarantees each changed manifest is judged by exactly one of them — so you never get the same finding twice, and you never validate a state that never actually deploys.

Findings are change-aware: a finding on a resource the PR itself changed is blocking; a finding that only surfaced because a shared base or component the PR touched feeds that resource is warning-only. Introducing a new policy therefore can't break legacy code the PR didn't touch.


Checks at a Glance

The registry groups its checks into two families. The complete, current ID list lives in the CI.md reference rather than being duplicated here.

  • Resource compliance: namespace declaration, Pod Security Admission labels, RBAC read-only aggregation and wildcard bans, ClusterRoleBinding sanity, ArgoCD sync-options, image digest pinning and explicit registry hosts, named ports, pod-spec defaults (securityContext, resources), unresolved placeholders, and cluster-identity copy/paste.
  • Runtime validation: 1:1 ports of the API server's admission rules across apps, batch, core, networking, policy, RBAC, storage and more, plus the NetworkAttachmentDefinition/OVN family. Each cites the upstream function it was ported from and is verified on every CI run.
  • Gated steps: linters, CEL, Kustomize Fix, scaffold checks, AVP, and Kyverno each have a stable ID for --enable-checks / --disable-checks.

Modes

Mode Command Changeset Source
Full pipeline pipeline --url <repo> --pr <n> PR's changed files via the forge API
Local PR check pipeline --revision <sha> --target-branch <branch> git diff <target>...<revision>
Working-tree diff test Uncommitted changes in the current tree
Directory scan test [dirs...] / test --dirs Every file under the given paths
Full repo scan test --all Every file, every overlay — ignores git state entirely
Ad-hoc overlay build build-yaml --app <a> --cluster <c> Targeted: the given app's base/ + overlays/<cluster> only

test accepts the same scoping and check-enablement flags as pipeline, so a failing CI run reproduces on your laptop with no remote and no PR.


GitHub

https://github.com/ArthurVardevanyan/k8s-gitops-ci

Install
go install github.com/ArthurVardevanyan/k8s-gitops-ci/cmd/k8s-gitops-ci@latest
Usage
# Full CI pipeline: PR checks, linting, static checks, resource compliance.
k8s-gitops-ci pipeline --url https://github.com/<org>/<repo> --pr 123

# Run every validator against the working tree (no PR/remote needed).
k8s-gitops-ci test ./kubernetes

# Full-repo scan, printing only failing sections.
k8s-gitops-ci test --all --quiet

# Build rendered YAML for a specific app/cluster overlay.
k8s-gitops-ci build-yaml --app my-app --cluster my-cluster
Documentation
  • ARCHITECTURE.md — runtime flow, package map, "where do I find X?"
  • CI.md — pipeline phases, every mode, the full registered-check list, finding classification
  • DEVELOPMENT.md — build/test/lint, repository structure, design conventions
  • HOOKS.md — the test.sh contract and the /hook-test security model
  • EXEMPTIONS.md — the exemption framework: annotation vs. selector modes, exemptable check IDs
  • TEKTON.md — the repo's own Pipelines-as-Code setup and caching
  • RELEASE.md — VERSION-file versioning, the release/RC flow, published artifacts
  • SECURITY.md — trust model, exec.Command audit, file-permission rationale
  • SCHEMAS.md — embedded kubeconform schemas / Kyverno policies, and how to supply your own



Timeline / Process

  • Shell Scripts — “Does It Build?”

    December 2022 – February 2023

    GitOps overlays were multiplying across many apps, and nothing verified that they still rendered before ArgoCD tried to sync them.

    • December 2022: First per-app test.sh: a loop over */overlays/* running kustomize build.
    • February 2023: test.sh rolled out app by app. Runs were local, serial, and per-app; there was no pipeline yet.
    • Key Tech: Kustomize, Bash.
  • Pipelines-as-Code & the First Real CI

    February – March 2023

    The scripts moved into a Tekton pipeline triggered by Pipelines-as-Code.

    • February 2023: First Tekton PipelineRun, run on every pull request, with AVP rendering added.
    • March 2023: Change detection maps a PR's changed files to the overlays they affect, with the first PR comment output.
    • March 2023: Helm rendering and kubeconform schema validation added; kubeconform becomes blocking.
    • Key Tech: Tekton, Pipelines-as-Code, Kustomize, Helm, AVP, kubeconform.
  • Hardening & the Lint Suite

    April 2023 – December 2024

    With rendering and schema validation in place, attention turned to the quality of everything else in the repo.

    • 2023: Pinned pipeline images, a restricted git-clone task, and regular kubeconform schema refreshes.
    • November 2023: markdownlint, prettier, and shellcheck added to the pipeline.
    • December 2023: pre-commit hooks (gitleaks, shellcheck, checkov, markdownlint, prettier), followed by a conventional-commit check in January 2024.
    • December 2024: CI now fails when test.sh is missing or invalid, and the pipeline standardizes on one shared builder image.
    • Size: about 3,000 lines of Bash across ~106 test.sh files.
  • Reusable Tasks & a Dedicated Overlay Repo

    2025

    Pipeline logic was copy-pasted per repository, so it was extracted into versioned, reusable tasks.

    • March 2025: New overlay repository with a full inline-Bash pipeline.
    • July 2025: Tasks published as a versioned catalog that repositories resolve remotely instead of embedding.
    • July 2025: First Go code: a standalone OVN-aware NetworkAttachmentDefinition validator, the ancestor of today's k8scni checks.
    • October 2025: Lint-only pipeline: a fast path that skips builds and kubeconform.
    • Key Tech: Tekton tasks, GoReleaser, kubeconform, a first Go validator.
  • test-utils.sh — Bash at Its Limit

    October 2025 – June 2026

    A shared library replaced the copy-pasted logic. It grew roughly 20× in eight months.

    • October 2025: test-utils.sh v1 (108 lines) with change-scoped overlay selection.
    • January 2026: Scaffold drift detection: do overlays still match the templates they were generated from?
    • February 2026: golangci-lint added, and parallel overlay builds through background subshells.
    • March 2026: kustomize edit fix normalization, PR checklist and title checks, and startingCSV and scaffold checks.
    • June 2026: test-utils.sh peaks at 2,107 lines. Testing and parallelizing it had become the bottleneck, which motivated the rewrite.
  • The Go Rewrite

    June – July 2026

    The multi-task Bash pipeline was replaced by a single Go binary, with no shared volume needed to pass state between tasks.

    • June 2026: The Go pipeline runs in shadow (non-blocking) mode alongside the Bash pipeline.
    • June 2026: Rewrite merged: ~20k lines of Go covering 23 validation steps, four build strategies (Kustomize, Helm, each with or without AVP), and embedded schemas and policies.
    • June 2026: Parallelism across linters, static checks, and per-overlay builds, plus selective builds of only the overlays a change reaches.
    • June 2026: One unified report: about ten per-check comments collapse into a single PR comment.
    • July 2026: Multi-arch images (linux/amd64 + linux/arm64) through ko, and a new named-ports check.
    • Key Tech: Go, Kustomize, Helm, kubeconform, Kyverno, ko, GoReleaser.
  • Standalone Core & Provider Split

    July 2026

    The generic engine was separated from organization-specific behavior, and the last Bash scaffolding was removed.

    • July 2026: Core/org split: organization-specific behavior moved behind provider interfaces (branding, comment policy, secret backend, cluster metadata).
    • July 2026: Legacy Bash shim decommissioned: test.sh became declarative config plus hook functions.
    • July 2026: The generic engine is extracted into its own standalone, open-source module.
    • July 2026: Hooks, AVP/Helm detection, Kyverno, and NetworkAttachmentDefinition validation wired into the pipeline, with real per-app scaffold drift detection.
    • July 2026: The documentation suite is published: ARCHITECTURE, CI, HOOKS, EXEMPTIONS, RELEASE, TEKTON, and SECURITY.
  • Exemptions, Releases & Runtime Validation

    August – September 2026

    • August 2026: Unified exemption framework: annotation-based and repo-wide selectors, both fail-closed.
    • August 2026: Releases: VERSION becomes the single source of truth, with a bump-correctness gate and auto-cut RC pre-releases.
    • August 2026: Dual-pass compliance, and a live replay of recent HomeLab PRs as a false-positive gate.
    • August 2026: Kubernetes admission rules ported 1:1 into the binary, each citing the upstream function it came from, with a CI job that breaks if upstream changes.
    • September 2026: CEL validation for CRD x-kubernetes-validations rules.
  • Multi-Forge, Distribution & Stabilization

    September – November 2026

    • September 2026: GitLab CI support through an explicit --forge flag and glab integration.
    • September 2026: A Containerfile based on Red Hat UBI 10 Minimal for distribution as a container image.
    • September 2026: Image building moves from Tekton to GitHub Actions, publishing a multi-arch index to GHCR.
    • October 2026: Attribution and classification fixes, Helm-template exclusions, and clearer AVP errors.
    • November 4, 2026: Scaffold drift in edited overlays treated as pre-existing when the PR adds none.
    • November 9, 2026: Tekton and GitHub Actions usage guides added to the docs suite.
    • November 10, 2026: Local usage guide added; named-ports validator gains comma-list annotation exemptions.
    • November 11, 2026: Static checks now warn on missing probes (liveness, readiness, startup).