Hamburger Cross Icon
Kubernetes Collector - Lunar Collector

Kubernetes Collector

Collector Stable OrchestrationContainersCi Cd

Parse Kubernetes YAML manifests to extract workloads, containers, resource limits, probes, PodDisruptionBudgets, and HorizontalPodAutoscalers. Capture kubectl commands in CI for deployment traceability.

Add k8s to your lunar-config.yml:
uses: github://earthly/lunar-lib/collectors/k8s@v1.0.5

What This Integration Collects

This integration includes 2 collectors that gather metadata from your systems.

Collector code

k8s

Parses all Kubernetes manifests in the repository using kubeconform validation and collects:

  • Manifest validity and parse errors
  • Workloads (Deployments, StatefulSets, DaemonSets, Jobs, CronJobs)
  • Container specs with resource requests/limits and probes
  • PodDisruptionBudgets (PDBs)
  • HorizontalPodAutoscalers (HPAs)
kubernetes k8s deployment pods containers resources probes pdb hpa
Book a demo
Collector ci-after-command

cicd

Records every kubectl command executed in CI pipelines along with the kubectl client version. Writes command strings and version info to .k8s.cicd for audit trails and deployment traceability (kubectl apply, kubectl rollout, etc.).

kubectl kubernetes ci kubectl apply kubectl rollout deployment tracking ci commands
Book a demo

How Collectors Fit into Lunar

Lunar watches your code and CI/CD systems to collect SDLC data from config files, test results, IaC, deployment configurations, security scans, and more.

Collectors are the automatic data-gathering layer. They extract structured metadata from your repositories and pipelines, feeding it into Lunar's centralized database where guardrails evaluate it to enforce your engineering standards.

Learn How Lunar Works
1
Collectors Gather Data This Integration
Triggered by code changes or CI pipelines, collectors extract metadata from config files, tool outputs, test results, and scans
2
{ } Centralized as JSON
All data merged into each component's unified metadata document
3
Guardrails Enforce Standards
Real-time feedback in PRs and AI workflows

Example Collected Data

This collector writes structured metadata to the Component JSON. Here's an example of the data it produces:

{ } component.json Component JSON
{
  "k8s": {
    "source": {
      "tool": "kubeconform",
      "version": "0.6.7"
    },
    "manifests": [
      {
        "path": "deploy/deployment.yaml",
        "valid": true,
        "resources": [
          {"kind": "Deployment", "name": "payment-api", "namespace": "payments"}
        ]
      }
    ],
    "workloads": [
      {
        "kind": "Deployment",
        "name": "payment-api",
        "namespace": "payments",
        "path": "deploy/deployment.yaml",
        "replicas": 3,
        "containers": [
          {
            "name": "api",
            "image": "gcr.io/acme/payment-api:v1.2.3",
            "has_resources": true,
            "has_requests": true,
            "has_limits": true,
            "cpu_request": "100m",
            "cpu_limit": "500m",
            "memory_request": "128Mi",
            "memory_limit": "512Mi",
            "has_liveness_probe": true,
            "has_readiness_probe": true,
            "runs_as_non_root": true,
            "read_only_root_fs": true,
            "privileged": false
          }
        ]
      }
    ],
    "pdbs": [
      {
        "name": "payment-api-pdb",
        "namespace": "payments",
        "path": "deploy/pdb.yaml",
        "target_workload": "payment-api",
        "min_available": 2
      }
    ],
    "hpas": [
      {
        "name": "payment-api-hpa",
        "namespace": "payments",
        "path": "deploy/hpa.yaml",
        "target_workload": "payment-api",
        "min_replicas": 3,
        "max_replicas": 10
      }
    ],
    "cicd": {
      "cmds": [
        {"cmd": "kubectl apply -f deploy/", "version": "1.29.2"},
        {"cmd": "kubectl rollout status deployment/payment-api", "version": "1.29.2"}
      ],
      "source": {"tool": "kubectl", "integration": "ci"}
    }
  }
}

Configuration

Configure this collector in your lunar-config.yml.

Inputs

Input Required Default Description
find_command Optional find . -type f \( -name '*.yaml' -o -name '*.yml' \) Command to find K8s manifest files (must output one file path per line)

Documentation

View on GitHub

Kubernetes Collector

Parses Kubernetes manifests and tracks kubectl commands in CI.

Overview

This collector finds all Kubernetes YAML manifests in a repository and validates them using kubeconform. It extracts structured information about workloads (Deployments, StatefulSets, DaemonSets, Jobs, CronJobs), their container specifications including resource limits and probes, PodDisruptionBudgets, and HorizontalPodAutoscalers. It also intercepts kubectl commands during CI runs so deployment invocations (apply, rollout, etc.) are recorded alongside the manifest data.

Collected Data

This collector writes to the following Component JSON paths:

Path Type Description
.k8s.source object Tool metadata (tool name and version)
.k8s.manifests[] array Parsed K8s manifests with validity and resources
.k8s.workloads[] array Workload resources with container specs
.k8s.pdbs[] array PodDisruptionBudgets
.k8s.hpas[] array HorizontalPodAutoscalers
.k8s.cicd object kubectl CI command tracking (commands + client version)

Collectors

This integration provides the following collectors (use include to select a subset):

Collector Description
k8s Parses Kubernetes manifests, workloads, PodDisruptionBudgets, and HorizontalPodAutoscalers
cicd Tracks all kubectl commands executed in CI pipelines (apply, rollout, etc.)

Installation

Add to your lunar-config.yml:

collectors:
  - uses: github://earthly/lunar-lib/collectors/k8s@v1.0.0
    on: ["domain:your-domain"]  # Or use tags like [kubernetes, backend]
    # with:
    #   find_command: "find ./deploy -name '*.yaml'"  # Custom find command

Open Source

This collector is open source and available on GitHub. Contribute improvements, report issues, or fork it for your own use.

View Repository

Ready to Automate Your Standards?

See how Lunar can turn your AGENTS.md, engineering wiki, compliance docs, or postmortem action items into automated guardrails with our 100+ built-in guardrails.

Works with any process
check AI agent rules & prompt files
check Post-mortem action items
check Security & compliance policies
check Testing & quality requirements
Automate Now
Paste your AGENTS.md or manual process doc and get guardrails in minutes
Book a Demo