- 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.
54 lines
1.2 KiB
Terraform
54 lines
1.2 KiB
Terraform
# PostgreSQL Kubernetes module for HAPI
|
|
# Manages Kubernetes resources for PostgreSQL deployment
|
|
|
|
terraform {
|
|
required_providers {
|
|
kubernetes = {
|
|
source = "hashicorp/kubernetes"
|
|
version = "~> 2.0"
|
|
}
|
|
}
|
|
}
|
|
|
|
# Data source to get Kubernetes cluster info
|
|
data "kubernetes_namespace" "postgres" {
|
|
metadata {
|
|
name = "postgres"
|
|
}
|
|
}
|
|
|
|
# Kubernetes resources
|
|
module "k8s_resources" {
|
|
source = "./k8s"
|
|
|
|
environment = var.environment
|
|
postgres_image = var.postgres_image
|
|
postgres_db = var.postgres_db
|
|
storage_size = var.storage_size
|
|
cpu_request = var.cpu_request
|
|
cpu_limit = var.cpu_limit
|
|
memory_request = var.memory_request
|
|
memory_limit = var.memory_limit
|
|
}
|
|
|
|
# Outputs
|
|
output "statefulset_name" {
|
|
description = "Name of the PostgreSQL StatefulSet"
|
|
value = module.k8s_resources.statefulset_name
|
|
}
|
|
|
|
output "service_name" {
|
|
description = "Name of the PostgreSQL Service"
|
|
value = module.k8s_resources.service_name
|
|
}
|
|
|
|
output "service_endpoint" {
|
|
description = "Endpoint for the PostgreSQL Service"
|
|
value = module.k8s_resources.service_endpoint
|
|
}
|
|
|
|
output "pvc_name" {
|
|
description = "Name of the PostgreSQL PVC"
|
|
value = module.k8s_resources.pvc_name
|
|
}
|