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?