Kubernetes Deployment Guide for Dutchie Backend
Prerequisites
- Access to your remote Kubernetes cluster
kubectlconfigured to connect to your cluster- Docker installed locally (to build the image)
- Access to a Docker registry (Docker Hub, Google Container Registry, etc.)
Step-by-Step Deployment
1. Build and Push Docker Image
# Navigate to backend directory
cd /home/kelly/dutchie-menus/backend
# Build the Docker image
docker build -t your-registry/dutchie-backend:latest .
# Log in to your Docker registry (example for Docker Hub)
docker login
# Push the image
docker push your-registry/dutchie-backend:latest
2. Update Kubernetes Manifests
Edit the following files with your actual values:
k8s/secret.yaml - Add your database and service credentials
k8s/deployment.yaml - Replace YOUR_REGISTRY/dutchie-backend:latest with your actual image name
3. Deploy to Kubernetes
# Connect to your remote cluster (method depends on your provider)
# Example for GKE:
# gcloud container clusters get-credentials YOUR_CLUSTER --region YOUR_REGION
# Example for AWS EKS:
# aws eks update-kubeconfig --name YOUR_CLUSTER --region YOUR_REGION
# Verify connection
kubectl cluster-info
# Apply the manifests
kubectl apply -f k8s/configmap.yaml
kubectl apply -f k8s/secret.yaml
kubectl apply -f k8s/deployment.yaml
kubectl apply -f k8s/service.yaml
# Check deployment status
kubectl get deployments
kubectl get pods
kubectl get services
4. Get Your Public IP
# Wait for LoadBalancer to provision (this may take 2-5 minutes)
kubectl get service dutchie-backend --watch
# Once EXTERNAL-IP shows an IP address (not <pending>), that's your public IP
kubectl get service dutchie-backend
The output will look like:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
dutchie-backend LoadBalancer 10.0.45.123 203.0.113.45 80:30123/TCP 2m
Your API will be available at: http://203.0.113.45 (use your actual EXTERNAL-IP)
5. Update WordPress Plugin
Update the "Dutchie Menus Settings" in your WordPress site:
- API URL:
http://YOUR_EXTERNAL_IP(orhttps://your-domain.comif you set up DNS)
6. Verify Deployment
# Check pod logs
kubectl logs -l app=dutchie-backend --tail=100
# Test the health endpoint
curl http://YOUR_EXTERNAL_IP/health
Updating the Deployment
When you make changes to your code:
# 1. Build new image with a tag
docker build -t your-registry/dutchie-backend:v1.1 .
docker push your-registry/dutchie-backend:v1.1
# 2. Update deployment
kubectl set image deployment/dutchie-backend backend=your-registry/dutchie-backend:v1.1
# 3. Check rollout status
kubectl rollout status deployment/dutchie-backend
Troubleshooting
# View pod logs
kubectl logs -l app=dutchie-backend --tail=100 --follow
# Describe pod (shows events and errors)
kubectl describe pod -l app=dutchie-backend
# Get into a pod shell
kubectl exec -it $(kubectl get pod -l app=dutchie-backend -o jsonpath='{.items[0].metadata.name}') -- sh
# Check service
kubectl describe service dutchie-backend
Setting up HTTPS (Optional but Recommended)
For production, you should use HTTPS. Options:
- Ingress with cert-manager (recommended for most cases)
- Cloud provider's load balancer with SSL certificate
- Cloudflare in front of your LoadBalancer
Let me know if you need help setting up HTTPS!
Clean Up
To remove everything:
kubectl delete -f k8s/