Organizing and scaling your Kubernetes manifests becomes much simpler when you adopt a consistent directory structure and leverage Kustomize. In this guide, we’ll walk through:Documentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.
- Defining a clear directory layout
- Deploying resources manually with
kubectl - Introducing Kustomize for centralized and per-directory customization
Directory Layout
Under thek8s/ folder, structure your manifests by component:
| Directory | Components |
|---|---|
| k8s/api | API Deployment & Service |
| k8s/cache | Redis Deployment, Service & Credentials |
| k8s/db | MongoDB Deployment, Service & Credentials |
Sample Manifests
Database Deployment (db/db-depl.yaml)
Redis Service (cache/redis-service.yaml)
Redis Credentials (cache/redis-config.yaml)
Manual Deployment
Apply each directory in sequence:Make sure your
kubectl context is pointed to the correct cluster and you have permission to create resources.Cleaning Up
Introducing Kustomize
Kustomize lets you define and compose resources without template syntax. Start by creating a rootkustomization.yaml under k8s/:
kubectl’s built-in Kustomize support:
You can apply overlays without installing the standalone Kustomize binary by running:See [Kubectl apply documentation].
Per-Directory Kustomization
For better modularity, place akustomization.yaml in each subfolder.
api/kustomization.yaml
cache/kustomization.yaml
db/kustomization.yaml
kustomization.yaml to reference directories: