name: k8s-lint description: Kubernetes YAML validation - Use kube-linter and kubeconform to check K8s config security and best practices
Kubernetes Lint Skill
π Overview
This skill uses kube-linter and kubeconform for dual validation of Kubernetes YAML configurations, ensuring:
- π Security (RBAC, Pod Security, NetworkPolicy)
- β Schema validation (K8s API spec compliance)
- β‘ Resource limit configuration
- π‘οΈ Best practices compliance
π§ Prerequisites
| Tool | Purpose | Windows | Linux/Mac |
|---|---|---|---|
| kube-linter | Best practices check | scoop install kube-linter |
brew install kube-linter |
| kubeconform | Schema validation | scoop install kubeconform |
brew install kubeconform |
| kubectl | (Optional) Cluster validation | scoop install kubectl |
brew install kubectl |
π Usage
Check single file:
# Windows
.\.agent\skills\k8s-lint\scripts\lint.ps1 -File deployment.yaml
# Linux/Mac
./agent/skills/k8s-lint/scripts/lint.sh deployment.yaml
Check entire directory:
# Windows
.\.agent\skills\k8s-lint\scripts\lint.ps1 -Path .\k8s -Recursive
# Linux/Mac
./.agent/skills/k8s-lint/scripts/lint.sh -r k8s/
π― What It Checks
Security Checks
- β Prohibit privileged containers
- β Prohibit hostNetwork/hostPID
- β Require readOnlyRootFilesystem
- β Run as non-root user
- β Capabilities whitelist
Resource Management
- β CPU/Memory limits set
- β liveness/readiness probes
- β Pod Disruption Budget
- β HPA configuration check
Best Practices
- β Image pull policy
- β Don't use latest tag
- β Service Account configuration
- β Label/Annotation standards
π Output Example
βΈοΈ Kubernetes Lint - Checking config files...
ββββββββββββββββββββββββββββββββββββββββ
π Schema Validation (kubeconform)
ββββββββββββββββββββββββββββββββββββββββ
β
deployment.yaml - valid
β
service.yaml - valid
β ingress.yaml - invalid: Missing required field: spec.rules
ββββββββββββββββββββββββββββββββββββββββ
π‘οΈ Best Practices Check (kube-linter)
ββββββββββββββββββββββββββββββββββββββββ
deployment.yaml: (object: <no namespace>/nginx-deployment apps/v1, Kind=Deployment)
β οΈ no-read-only-root-fs: Container "nginx" does not have a read-only root file system
β cpu-requirements: Container "nginx" has no CPU limits
β memory-requirements: Container "nginx" has no memory limits
π Check Results:
β Errors: 3
β οΈ Warnings: 1
βοΈ Configuration
Create .kube-linter.yaml:
checks:
exclude:
- no-read-only-root-fs # Temporarily allow writable root filesystem
include:
- cpu-requirements
- memory-requirements
- privileged-containers
- run-as-non-root
customChecks: []