# 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 ```bash kubectl apply -k infra/k8s/staging ``` ### Production Environment ```bash kubectl apply -k infra/k8s/production ``` ### Dry Run ```bash 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-secrets` with keys: - `username`: PostgreSQL username - `password`: PostgreSQL password ## Configuration Each environment's `kustomization.yaml` customizes: - `namePrefix`: Environment-specific prefix - `commonLabels`: Environment label applied to all resources - `patches`: Adds environment label to Service, PVC, and StatefulSet - `configMapGenerator`: Creates ConfigMap with `ENVIRONMENT` value