- Create infrastructure for PostgreSQL StatefulSet in Kubernetes - Implement environment-specific configurations (staging/production) - Add Kustomize overlays for deterministic deployments - Document deployment process in AGENTS.md and infra/k8s/README.md - Include Makefile and helper scripts for easy management New directories: - infra/k8s/base/ - Shared resources (StatefulSet, Service, PVC, Namespace) - infra/k8s/staging/ - Staging environment overlay - infra/k8s/production/ - Production environment overlay Key files: - infra/k8s/base/kustomization.yaml - infra/k8s/staging/kustomization.yaml - infra/k8s/production/kustomization.yaml - infra/k8s/README.md Resources are prefixed by environment (staging-, production-) and deployed to the postgres namespace.
1.6 KiB
1.6 KiB
PostgreSQL Kubernetes Deployments
This directory contains Kustomize configurations for deploying PostgreSQL to different environments.
Directory Structure
k8s/
├── base/ # Base resources shared across environments
│ ├── kustomization.yaml
│ ├── namespace.yaml
│ ├── statefulset.yaml
│ ├── service.yaml
│ └── pvc.yaml
├── staging/ # Staging environment configuration
│ └── kustomization.yaml
├── production/ # Production environment configuration
│ └── kustomization.yaml
└── README.md
Usage
Staging Environment
kubectl apply -k infra/k8s/staging
Production Environment
kubectl apply -k infra/k8s/production
Dry Run
kubectl apply -k infra/k8s/staging --dry-run=client
Resource Naming
Resources are prefixed with the environment name:
- Staging:
staging-postgres-* - Production:
production-postgres-*
Environment Variables
The ENVIRONMENT variable is embedded in ConfigMaps:
- Staging:
ENVIRONMENT=staging - Production:
ENVIRONMENT=production
Secrets
The following secrets are expected in the postgres namespace:
postgres-secretswith keys:username: PostgreSQL usernamepassword: PostgreSQL password
Configuration
Each environment's kustomization.yaml customizes:
namePrefix: Environment-specific prefixcommonLabels: Environment label applied to all resourcespatches: Adds environment label to Service, PVC, and StatefulSetconfigMapGenerator: Creates ConfigMap withENVIRONMENTvalue