feat: Add PostgreSQL Kubernetes deployment with Kustomize

- 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.
This commit is contained in:
Bobby committed 2026-11-18 15:29:00 -05:00
1 parent 9568d4ca6e
commit 88235fc824
26 files changed
+1407 -14

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
#!/bin/bash
# Script to get kubeconfig from Terraform or Linode CLI
# Usage: ./get-kubeconfig.sh [environment]
set -e
ENVIRONMENT="${1:-staging}"
OUTPUT_FILE="${2:-/home/bobby/.kube/config}"
echo "Getting kubeconfig for $ENVIRONMENT environment..."
# Check if Terraform is available and state exists
if command -v terraform &> /dev/null && [ -f "infra/terraform.tfstate" ]; then
echo "📦 Getting kubeconfig from Terraform state..."
# Get kubeconfig from postgres module output
KUBECONFIG=$(terraform output -json | jq -r '.postgres.value.kubeconfig // empty')
if [ -n "$KUBECONFIG" ]; then
echo "$KUBECONFIG" > "$OUTPUT_FILE"
echo "✅ Kubeconfig saved to $OUTPUT_FILE"
else
echo "⚠️ No kubeconfig found in Terraform state"
echo "You may need to run 'terraform apply' first to get the cluster kubeconfig"
fi
elif command -v linode-cli &> /dev/null; then
echo "📦 Getting kubeconfig from Linode CLI..."
# List clusters to find the right one
CLUSTERS=$(linode lke clusters-list --json)
CLUSTER_ID=$(echo "$CLUSTERS" | jq -r ".[] | select(.label | contains(\"$ENVIRONMENT\")) | .id" 2>/dev/null | head -1)
if [ -n "$CLUSTER_ID" ]; then
echo "Found cluster $CLUSTER_ID"
linode lke cluster-kubeconfig "$CLUSTER_ID" --raw > "$OUTPUT_FILE"
echo "✅ Kubeconfig saved to $OUTPUT_FILE"
else
echo "⚠️ No Linode cluster found for $ENVIRONMENT"
echo "Available clusters:"
linode lke clusters
fi
else
echo "ℹ️ No Terraform or Linode CLI found"
echo "Please manually get your kubeconfig from the Linode Dashboard:"
echo "1. Go to Kubernetes in Linode Dashboard"
echo "2. Select your cluster (hapi-$ENVIRONMENT)"
echo "3. Click 'Kubeconfig' tab and copy the config"
echo "4. Save to $OUTPUT_FILE"
fi
echo ""
echo "Verify your setup with:"
echo " kubectl cluster-info"