Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

Kustomize Example

This example demonstrates a complete kustomize setup with base/overlays pattern using yq-eval.

Structure

base/                    # Base resources
  deployment.yaml        # Deployment with ${APP} variable
  ingress.yaml          # Ingress with ${APP} and ${DOMAIN} variables
  service.yaml          # Service with ${APP} variable
  kustomization.yaml    # Base kustomization with local-config

components/
  yq-eval/              # Reusable yq-eval component
    yq-eval.yaml        # Function configuration
    kustomization.yaml

overlays/
  dev/                  # Development environment
    kustomization.yaml  # Sets DOMAIN=dev.example
  prod/                 # Production environment
    kustomization.yaml  # Sets DOMAIN=prod.example

Running the Examples

Development Environment

$ kustomize build --enable-alpha-plugins --enable-exec overlays/dev

This will generate resources with:

  • APP=myapp (from base)
  • DOMAIN=dev.example (from dev overlay)
  • Ingress host: myapp.dev.example

Production Environment

$ kustomize build --enable-alpha-plugins --enable-exec overlays/prod

This will generate resources with:

  • APP=myapp (from base)
  • DOMAIN=prod.example (from prod overlay)
  • Ingress host: myapp.prod.example

Key Features Demonstrated

  1. Base/Overlays Pattern: Common resources in base, environment-specific config in overlays
  2. ConfigMap Merging: Overlays merge additional variables into local-config
  3. Component Reuse: The yq-eval component is shared across overlays
  4. Variable Substitution: All ${VAR} placeholders are replaced with values from local-config

How It Works

  1. Base defines local-config ConfigMap with APP=myapp
  2. Each overlay merges additional variables (e.g., DOMAIN)
  3. The yq-eval component reads from local-config and applies transformations
  4. All resources with yq-eval annotation get their variables substituted