Kubernetes Deployment
This skill covers deploying applications to Kubernetes clusters, managing Persistent Volume Claims (PVCs), and working with Kubernetes jobs in this monorepo.
Overview
The monorepo uses Kubernetes for deploying the caelundas ephemeris calendar generator as a scheduled job. The deployment workflow involves:
- •Building Docker images for linux/amd64
- •Pushing to GitHub Container Registry (GHCR)
- •Deploying to K8s using Helm charts
- •Managing PVCs for input/output data persistence
For comprehensive deployment patterns and infrastructure details, see infrastructure/AGENTS.md.
Key Concepts
Helm Charts
The monorepo includes a reusable Helm chart at infrastructure/helm/kubernetes-job for deploying batch jobs. Key features:
- •Auto-generated names: Each deployment creates uniquely named resources
- •PVC management: Mounts input and output volumes
- •Image pull secrets: Supports private registries (GHCR)
- •Resource limits: Configurable CPU and memory constraints
Deployment Workflow
# Build Docker image for K8s platform nx run caelundas:docker-build # Deploy to K8s cluster (generates unique job name) nx run caelundas:helm-upgrade # Retrieve output files after job completion nx run caelundas:kubernetes-copy-files # Clean up completed jobs nx run caelundas:kubernetes-uninstall
PVC Strategy
Applications use two PVCs:
- •Input PVC: Configuration files, environment-specific data (read-only)
- •Output PVC: Generated artifacts, logs, results (read-write)
The kubernetes-copy-files target synchronizes output files back to local filesystem after job completion.
Project-Specific Patterns
caelundas Deployment
See applications/caelundas/AGENTS.md for detailed caelundas deployment workflows, including:
- •Docker multi-stage build patterns
- •Environment variable management in K8s
- •Output file retrieval from completed jobs
- •Debugging failed K8s jobs
Key targets:
- •
nx run caelundas:docker-build- Builds for linux/amd64 - •
nx run caelundas:helm-upgrade- Deploys with auto-generated name - •
nx run caelundas:kubernetes-copy-files- Retrieves output from PVC - •
nx run caelundas:kubernetes-uninstall- Removes completed jobs
Infrastructure Configuration
Helm Values
Configure deployments via values.yaml:
image:
repository: ghcr.io/jimmypaolini/caelundas
tag: latest
pullPolicy: Always
resources:
limits:
memory: 2Gi
cpu: 1000m
volumes:
input:
name: caelundas-input
mountPath: /app/input
output:
name: caelundas-output
mountPath: /app/output
Kubernetes Context
Deployments use the K8s context from ~/Personal/lexico-prod-kubeconfig.yaml. Ensure the context is set before running deployment commands:
export KUBECONFIG=~/Personal/lexico-prod-kubeconfig.yaml kubectl config current-context
Common Tasks
Deploy New Version
# Build and push image nx run caelundas:docker-build # Deploy to cluster nx run caelundas:helm-upgrade
Check Job Status
# List all jobs kubectl get jobs -n default # Get job details kubectl describe job <job-name> # View logs kubectl logs job/<job-name>
Retrieve Results
# Copy files from output PVC nx run caelundas:kubernetes-copy-files # Or manually kubectl cp <pod-name>:/app/output ./output
Troubleshooting
Job fails to start:
- •Check image pull secrets:
kubectl get secret ghcr-credentials - •Verify image exists in registry:
docker pull ghcr.io/jimmypaolini/caelundas:latest - •Check PVC bindings:
kubectl get pvc
PVC mount failures:
- •Ensure PVCs exist:
kubectl get pvc - •Check access modes (ReadWriteOnce vs ReadWriteMany)
- •Verify storage class supports dynamic provisioning
Resource constraints:
- •Check node capacity:
kubectl describe nodes - •Adjust resource limits in values.yaml
- •Consider node selectors for specific workloads
Related Documentation
- •infrastructure/AGENTS.md - Infrastructure architecture
- •applications/caelundas/AGENTS.md - Caelundas deployment workflow
- •infrastructure/helm/kubernetes-job/README.md - Helm chart details
Best Practices
- •Always specify platform when building Docker images:
--platform linux/amd64 - •Use auto-generated names for jobs to avoid conflicts
- •Set resource limits to prevent OOM kills
- •Clean up completed jobs to avoid cluster bloat
- •Use image pull secrets for private registries
- •Monitor PVC usage to prevent disk pressure
- •Tag images with commit SHA for traceability