Skip to content

jsconsul/kustomize-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Kustomize Template

A comprehensive Kustomize template for deploying a multi-tier web application with environment-specific configurations. This template demonstrates best practices for managing Kubernetes deployments across different environments (test, staging, production) using Kustomize overlays.

Architecture Overview

This template deploys a web application consisting of:

  • Web Frontend: A web server (default port 80)
  • API Backend: A REST API service (default port 8000) with horizontal pod autoscaling
  • Database Jobs: CronJob for database maintenance tasks
  • External Secrets: Integration with Google Secret Manager
  • Service Mesh: Istio VirtualService for traffic routing

Project Structure

.
├── base/                           # Base Kubernetes manifests
│   ├── kustomization.yaml         # Main base kustomization
│   ├── api/                       # API service components
│   │   ├── deployment.yaml        # API deployment manifest
│   │   ├── service.yaml           # API service manifest
│   │   ├── hpa.yaml              # Horizontal Pod Autoscaler
│   │   └── kustomization.yaml    # API-specific kustomization
│   ├── web/                       # Web frontend components
│   │   ├── deployment.yaml        # Web deployment manifest
│   │   ├── service.yaml           # Web service manifest
│   │   └── kustomization.yaml    # Web-specific kustomization
│   └── cronjobs/                  # Scheduled jobs
│       └── sample.yaml            # Sample CronJob for DB tasks
└── overlays/                      # Environment-specific overlays
    ├── test/                      # Test environment
    │   ├── kustomization.yaml     # Test environment customizations
    │   ├── externalsecret.yaml    # External secret configuration
    │   ├── secretstore.yaml       # Secret store configuration
    │   └── vs.yaml               # Virtual service for routing
    ├── staging/                   # Staging environment
    │   ├── kustomization.yaml     # Staging environment customizations
    │   ├── externalsecret.yaml    # External secret configuration
    │   ├── secretstore.yaml       # Secret store configuration
    │   └── vs.yaml               # Virtual service for routing
    └── prod/                      # Production environment
        ├── kustomization.yaml     # Production environment customizations
        ├── externalsecret.yaml    # External secret configuration
        ├── secretstore.yaml       # Secret store configuration
        └── vs.yaml               # Virtual service for routing

Base Components

API Service

  • Deployment: Backend API service with configurable image
  • Service: ClusterIP service exposing port 8000
  • HPA: Horizontal Pod Autoscaler (1-4 replicas, 60% CPU threshold)

Web Service

  • Deployment: Frontend web server with configurable image
  • Service: ClusterIP service exposing port 80

CronJobs

  • Sample Job: Database maintenance task running daily at 3 AM
  • Connects to PostgreSQL database using external secrets

Environment Overlays

Each environment (test, staging, prod) includes:

Custom Configurations

  • Namespace: Environment-specific namespace (demo-test, demo-staging, demo-prod)
  • Images: Environment-specific container images from Google Artifact Registry
  • Resource Limits: CPU and memory allocations per environment

External Secrets Integration

  • SecretStore: Google Secret Manager integration
  • ExternalSecret: Automatic secret synchronization for database credentials

Istio Service Mesh

  • VirtualService: Traffic routing configuration
  • Gateway: Ingress traffic management
  • Host Mapping: Environment-specific domain routing

Prerequisites

Before using this template, ensure you have:

  1. Kustomize installed (kubectl includes Kustomize)
  2. External Secrets Operator deployed in your cluster
  3. Istio Service Mesh installed (for traffic management)
  4. Google Cloud project with Secret Manager enabled
  5. Artifact Registry repositories for container images

Usage

Deploy to Test Environment

kubectl apply -k overlays/test/

Deploy to Staging Environment

kubectl apply -k overlays/staging/

Deploy to Production Environment

kubectl apply -k overlays/prod/

Dry Run (Preview Changes)

kubectl diff -k overlays/test/

Generate Manifests Only

kubectl kustomize overlays/test/

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published