DEV Community

Shiva Charan
Shiva Charan

Posted on

πŸ“Kubernetes Project Folder Structure

A well-structured Kubernetes project repo usually looks like this:

k8s-project/
β”œβ”€β”€ README.md
β”œβ”€β”€ docs/
β”œβ”€β”€ manifests/
β”‚   β”œβ”€β”€ namespaces/
β”‚   β”œβ”€β”€ deployments/
β”‚   β”œβ”€β”€ services/
β”‚   β”œβ”€β”€ ingresses/
β”‚   β”œβ”€β”€ configmaps/
β”‚   β”œβ”€β”€ secrets/
β”‚   β”œβ”€β”€ storage/
β”‚   └── crds/
β”œβ”€β”€ overlays/
β”‚   β”œβ”€β”€ dev/
β”‚   β”œβ”€β”€ test/
β”‚   └── prod/
β”œβ”€β”€ charts/
β”œβ”€β”€ scripts/
β”œβ”€β”€ ci-cd/
└── templates/
Enter fullscreen mode Exit fullscreen mode

Now let's break down every folder, its purpose, what goes inside, and why it exists.


πŸ“˜ 1. README.md

Your project documentation.

  • Overview of the application
  • How to deploy
  • Pre-requisites (kubectl, kustomize, helm, cluster roles)
  • CI/CD instructions

πŸ“š 2. docs/ – Architecture Documentation

Used for:

  • Architecture diagrams
  • Flowcharts
  • Troubleshooting guides
  • Onboarding docs

Example:

docs/
β”œβ”€β”€ architecture.png
β”œβ”€β”€ sequence-flows.md
└── troubleshooting.md
Enter fullscreen mode Exit fullscreen mode

πŸ“¦ 3. manifests/ – Core Kubernetes YAML Files

This is your main folder containing all the raw Kubernetes manifests.

Typical structure:

manifests/
β”œβ”€β”€ namespaces/
β”‚   └── dev-namespace.yaml
β”‚   └── prod-namespace.yaml
β”œβ”€β”€ deployments/
β”‚   └── app-deployment.yaml
β”‚   └── worker-deployment.yaml
β”œβ”€β”€ services/
β”‚   └── app-service.yaml
β”‚   └── internal-service.yaml
β”œβ”€β”€ ingresses/
β”‚   └── app-ingress.yaml
β”œβ”€β”€ configmaps/
β”‚   └── app-configmap.yaml
β”œβ”€β”€ secrets/
β”‚   └── db-secret.yaml
β”œβ”€β”€ storage/
β”‚   β”œβ”€β”€ pv.yaml
β”‚   └── pvc.yaml
└── crds/
    └── custom-metrics.yaml
Enter fullscreen mode Exit fullscreen mode

Why this folder exists?

To organise all "base" Kubernetes resources cleanly so you don’t mix environments.


🧩 4. overlays/ – Environment-Specific Patches (Kustomize)

This folder is used if you use Kustomize for environment-specific overrides.

overlays/
β”œβ”€β”€ dev/
β”‚   β”œβ”€β”€ kustomization.yaml
β”‚   └── patch-replicas.yaml
β”œβ”€β”€ test/
β”‚   β”œβ”€β”€ kustomization.yaml
β”‚   └── patch-image-tag.yaml
└── prod/
    β”œβ”€β”€ kustomization.yaml
    └── patch-resources.yaml
Enter fullscreen mode Exit fullscreen mode

Purpose:

  • Change CPU/memory only in prod
  • Use latest tag in dev
  • Increase replicas per environment
  • Change configmaps per environment

β›΅ 5. charts/ – Helm Chart Folder

If the project is using Helm, you place custom charts here.

charts/
└── myapp/
    β”œβ”€β”€ templates/
    β”œβ”€β”€ values.yaml
    β”œβ”€β”€ values-prod.yaml
    └── Chart.yaml
Enter fullscreen mode Exit fullscreen mode

Use-cases:

  • Template large apps
  • Parameterize configurations
  • Reuse configs across multiple apps

πŸ”§ 6. scripts/ – Helper Scripts

Contains Bash/Python scripts for:

  • Deployment automation
  • kubectl wrappers
  • Cleanup scripts
  • Log collectors

Example:

scripts/
β”œβ”€β”€ deploy.sh
β”œβ”€β”€ validate-yamls.sh
└── cleanup.sh
Enter fullscreen mode Exit fullscreen mode

πŸ€– 7. ci-cd/ – Pipeline Definitions

Stores pipeline configuration for:

  • GitHub Actions
  • GitLab CI/CD
  • Azure DevOps
  • Jenkins
  • ArgoCD / FluxCD manifests

Example:

ci-cd/
β”œβ”€β”€ github-actions.yaml
β”œβ”€β”€ gitlab-ci.yaml
└── argo-app.yaml
Enter fullscreen mode Exit fullscreen mode

Purpose:
Automate deployments, validations, and image pushes.


🧱 8. templates/ – YAML Snippets / Boilerplate

Reusable YAML parts, such as:

  • Pod templates
  • Labels/annotations
  • Resource-block templates
  • Common affinity rules

Example:

templates/
β”œβ”€β”€ pod-template.yaml
β”œβ”€β”€ sidecar-template.yaml
└── affinity.yaml
Enter fullscreen mode Exit fullscreen mode

πŸ“ Example Real-World Workflow

A developer wants to deploy a new version to dev:

  1. Updates image version in overlays/dev/kustomization.yaml
  2. Runs
   kubectl apply -k overlays/dev
Enter fullscreen mode Exit fullscreen mode
  1. Kustomize merges: Base manifests (in manifests/) + Dev patches (in overlays/dev/)
  2. Resources get deployed to the cluster.

For Helm:

helm upgrade --install myapp charts/myapp -f charts/myapp/values-dev.yaml
Enter fullscreen mode Exit fullscreen mode

🎯 Summary Table

Folder Purpose
manifests/ Base Kubernetes YAMLs
overlays/ Environment overrides using Kustomize
charts/ Helm charts
scripts/ Deployment helper scripts
ci-cd/ Automation & pipelines
templates/ Reusable YAML snippets
docs/ Documentation & diagrams

Top comments (0)