|
| 1 | +--- |
| 2 | +title: "Kubernetes" |
| 3 | +linkTitle: "Kubernetes" |
| 4 | +weight: 55 |
| 5 | +description: "Kubernetes tooling standards: kustomize and kubeconform for manifest validation." |
| 6 | +--- |
| 7 | + |
| 8 | +Kubernetes projects use kustomize for rendering overlays and kubeconform for schema validation. Detection is automatic based on `kustomization.yaml` file presence -- no `.devrail.yml` language entry is needed. |
| 9 | + |
| 10 | +## Tools |
| 11 | + |
| 12 | +| Category | Tool | Purpose | |
| 13 | +|---|---|---| |
| 14 | +| Manifest Validation | kustomize build | Render overlays, catch structural errors | |
| 15 | +| Schema Validation | kubeconform | Validate against Kubernetes API schemas | |
| 16 | + |
| 17 | +All tools are pre-installed in the dev-toolchain container. Do not install them on the host. |
| 18 | + |
| 19 | +## Configuration |
| 20 | + |
| 21 | +### kustomize |
| 22 | + |
| 23 | +No config file required. Reads `kustomization.yaml` in each overlay directory. |
| 24 | + |
| 25 | +### kubeconform |
| 26 | + |
| 27 | +No config file required. Validates against built-in Kubernetes schemas. Override the target version if needed: |
| 28 | + |
| 29 | +```bash |
| 30 | +kustomize build overlays/production | kubeconform -strict -kubernetes-version 1.29.0 |
| 31 | +``` |
| 32 | + |
| 33 | +For CRDs, add additional schema sources: |
| 34 | + |
| 35 | +```bash |
| 36 | +kubeconform -strict \ |
| 37 | + -schema-location default \ |
| 38 | + -schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' |
| 39 | +``` |
| 40 | + |
| 41 | +## Makefile Targets |
| 42 | + |
| 43 | +| Target | Command | Description | |
| 44 | +|---|---|---| |
| 45 | +| `make lint` | `kustomize build <dir> \| kubeconform -strict -summary` | Validate each Kustomize overlay | |
| 46 | + |
| 47 | +Detection is automatic. Every directory containing `kustomization.yaml` is validated independently. |
| 48 | + |
| 49 | +## Pre-Commit Hooks |
| 50 | + |
| 51 | +### CI-Only (too slow for local hooks) |
| 52 | + |
| 53 | +Kustomize validation runs via `make lint` in CI. It is not configured as a local pre-commit hook because `kustomize build` may need to fetch remote bases. |
| 54 | + |
| 55 | +## Notes |
| 56 | + |
| 57 | +- **Kustomize is a companion tool, not a language.** No `.devrail.yml` entry needed. Auto-detected by `kustomization.yaml` presence. |
| 58 | +- **kubeconform replaces kubeval.** kubeval is deprecated. kubeconform is the maintained successor with better CRD support. |
| 59 | +- **Each overlay is validated independently.** The Makefile finds all `kustomization.yaml` files and validates each directory. |
| 60 | +- **CRD validation requires schema sources.** Core Kubernetes resources are validated by default. CRDs need additional schema locations configured. |
| 61 | +- **All tools are pre-installed in the dev-toolchain container.** Do not install them on the host. |
| 62 | +- For cross-cutting coding practices and git workflow standards, see [Coding Practices](/docs/standards/practices/). |
0 commit comments