Kubernetes Collector
Parse Kubernetes YAML manifests to extract workloads, containers, resource limits, probes, PodDisruptionBudgets, and HorizontalPodAutoscalers. Capture kubectl commands in CI for deployment traceability.
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.
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)
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.).
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 →Example Collected Data
This collector writes structured metadata to the Component JSON. Here's an example of the data it produces:
{
"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 GitHubKubernetes 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.
Common Use Cases
Explore guardrails that use data from Kubernetes Collector.
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.