In this guide, you’ll learn how to define and consume components in Kustomize. Components let you package optional features—such as additional resources, patches, ConfigMaps, or Secrets—into self-contained units. You can then import them in selected overlays without duplicating code, ensuring consistency and reducing configuration drift.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.
When to Use Components
Use components when an application offers optional features that only apply to some overlays. If a feature is required in all overlays, include it in your base. For features needed by only a subset, bundle them as components to avoid repetition.Visual Example
Consider three deployment environments:- dev (development)
- premium (for premium customers)
- standalone (self-hosted)
- Caching (backed by Redis) — enabled in premium and standalone
- External DB (Postgres) — enabled in dev and premium

caching and db) and import them selectively.

Component Features Table
| Component | Purpose | Overlays |
|---|---|---|
| caching | Redis Deployment & service | premium, standalone |
| db (External) | Postgres Deployment & DB secrets | dev, premium |
Project Structure
- base/: Common resources (e.g., API Deployment)
- components/: Feature directories (
caching/,db/) - overlays/: Environment-specific kustomizations
Database Component
The db component adds a Postgres deployment, a Secret for credentials, and patches your API Deployment.postgres-depl.yaml
Components require
kind: Component with the v1alpha1 API. Ensure you’re running Kustomize v4.x or later.kustomization.yaml (Component)
deployment-patch.yaml
This strategic merge patch injects the DB_PASSWORD from the Secret into your API Deployment:
Overlay Configuration
Each overlay’skustomization.yaml pulls in base plus the desired components.
Example: Dev Overlay
- premium overlay adds both
../../components/dband../../components/caching. - standalone overlay adds only
../../components/caching.