towerops/k8s
Graham McIntire 7339ac7eec
Add automatic database migrations on deployment
- Create Kubernetes Job to run migrations before deployment
- Update GitLab CI to execute migration job and wait for completion
- Ensures migrations run once per deployment in clustered environment
- Migration job uses PostgreSQL advisory locks to prevent race conditions
2026-01-03 15:50:01 -06:00
..
certificate.yaml Remove www subdomain from certificate and IngressRoute 2026-01-02 15:06:21 -06:00
deployment.yaml add sendgrid 2026-01-03 15:26:48 -06:00
Dockerfile Dockerfile improvements 2026-01-03 15:38:14 -06:00
ingressroute.yaml Remove www subdomain from certificate and IngressRoute 2026-01-02 15:06:21 -06:00
kustomization.yaml add sendgrid 2026-01-03 15:26:48 -06:00
migrate-job.yaml Add automatic database migrations on deployment 2026-01-03 15:50:01 -06:00
namespace.yaml Add Kubernetes deployment manifests for towerops.net 2026-01-02 14:38:52 -06:00
README.md add sendgrid 2026-01-03 15:26:48 -06:00
service-headless.yaml cluster 2026-01-02 15:29:02 -06:00
service.yaml Add Kubernetes deployment manifests for towerops.net 2026-01-02 14:38:52 -06:00

Kubernetes Deployment

Secrets Management

Secrets are stored in .envrc files (gitignored):

  • Project root .envrc - Used by direnv for local development
  • k8s/.envrc - Used by Kustomize for secret generation

Kustomize automatically generates the towerops-sendgrid Secret from k8s/.envrc using the secretGenerator in kustomization.yaml.

Both .envrc files should contain:

# SendGrid Configuration
SENDGRID_API_KEY=your-api-key-here
export SENDGRID_API_KEY

The KEY=VALUE format works for both Kustomize and direnv.

Deploying

Apply all resources using kustomize:

kubectl apply -k k8s/

Or individually:

kubectl apply -f k8s/namespace.yaml
kubectl apply -f k8s/secret.yaml
kubectl apply -f k8s/deployment.yaml
kubectl apply -f k8s/service.yaml
kubectl apply -f k8s/service-headless.yaml
kubectl apply -f k8s/certificate.yaml
kubectl apply -f k8s/ingressroute.yaml