- 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.
79 lines
1.9 KiB
YAML
79 lines
1.9 KiB
YAML
# Kustomize configuration for PostgreSQL Kubernetes resources
|
|
# Enables environment-specific customization and easy deployment
|
|
|
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
|
kind: Kustomization
|
|
|
|
resources:
|
|
- namespace.yaml
|
|
- pvc.yaml
|
|
- service.yaml
|
|
- statefulset.yaml
|
|
|
|
commonLabels:
|
|
app: postgres
|
|
managedBy: terraform
|
|
|
|
commonAnnotations:
|
|
description: "PostgreSQL StatefulSet for HAPI"
|
|
|
|
# Environment-specific configurations
|
|
namePrefix: staging-
|
|
|
|
# Environment variable ConfigMap for substitutions
|
|
configMapGenerator:
|
|
- name: env-vars
|
|
literals:
|
|
- ENVIRONMENT=${ENVIRONMENT:-staging}
|
|
|
|
# Apply environment label to resources
|
|
patches:
|
|
- target:
|
|
kind: Service
|
|
patch: |-
|
|
- op: add
|
|
path: /metadata/labels/environment
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: env-vars
|
|
key: ENVIRONMENT
|
|
- op: add
|
|
path: /spec/selector/environment
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: env-vars
|
|
key: ENVIRONMENT
|
|
- target:
|
|
kind: PersistentVolumeClaim
|
|
patch: |-
|
|
- op: add
|
|
path: /metadata/labels/environment
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: env-vars
|
|
key: ENVIRONMENT
|
|
- target:
|
|
kind: StatefulSet
|
|
patch: |-
|
|
- op: add
|
|
path: /metadata/labels/environment
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: env-vars
|
|
key: ENVIRONMENT
|
|
- op: add
|
|
path: /spec/selector/matchLabels/environment
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: env-vars
|
|
key: ENVIRONMENT
|
|
- op: add
|
|
path: /spec/template/metadata/labels/environment
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: env-vars
|
|
key: ENVIRONMENT
|
|
|
|
# Secrets can be injected via external Secret Manager or inline
|
|
# See docs/adr/0003-secrets-management.md for details
|