githubEdit

Kubernetes

Deploy moclojer to Kubernetes - Deployments, Services, ConfigMaps, and best practices for production-ready K8s deployments with health checks and scaling.

Deploy moclojer to Kubernetes for production-grade mock APIs with scaling and high availability.

📋 What You'll Build

  • ✅ Kubernetes Deployment

  • ✅ Service (ClusterIP/LoadBalancer)

  • ✅ ConfigMap for configuration

  • ✅ Health checks (liveness/readiness)

  • ✅ Resource limits

  • ✅ Horizontal Pod Autoscaling

🚀 Quick Start

1. ConfigMap for Configuration

# configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: moclojer-config
  namespace: default
data:
  moclojer.yml: |
    - endpoint:
        method: GET
        path: /health
        response:
          status: 200
          body: >
            {"status": "ok", "service": "moclojer"}

    - endpoint:
        method: GET
        path: /api/users
        response:
          status: 200
          body: >
            {"users": [{"id": 1, "name": "Alice"}]}

2. Deployment

3. Service

📦 Deploy

🔧 Advanced Configurations

Horizontal Pod Autoscaler

Ingress (NGINX)

✅ Best Practices

Do ✅:

  • Use ConfigMaps for configuration

  • Set resource limits

  • Configure health checks

  • Use specific image tags (not latest)

  • Enable horizontal scaling

Don't ❌:

  • Don't hardcode configs in images

  • Don't skip health checks

  • Don't use excessive resources

📚 See Also

Last updated

Was this helpful?