Mock Services Operations
This guide covers operational aspects of running Microcks mock services in Kubernetes environments.
Architecture Overview
┌──────────────────────┐
│ Staqr API Pod │
│ │
│ Uses connection: │
│ mock-optus-wsg │
└──────────┬───────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Kubernetes Cluster │
│ ┌─────────────────┐ ┌─────────────────────────────────┐ │
│ │ ConfigMap │ │ Microcks Pod │ │
│ │ │ │ │ │
│ │ connections: │ │ ┌─────────────────────────┐ │ │
│ │ optus: │───▶│ │ /soap/WsgService/9.2 │ │ │
│ │ endpoint: │ │ └─────────────────────────┘ │ │
│ │ microcks: │ │ │ │
│ │ 8080/... │ │ Port: 8080 (ClusterIP) │ │
│ └─────────────────┘ └─────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
Deployment
Mock services are deployed via Helm subchart and are only enabled in development:
| Environment | microcks.enabled | Behaviour |
|---|---|---|
| Development | true | Microcks deployed, mock connections active |
| Staging | false | Microcks not deployed, UAT connections |
| Production | false | Microcks not deployed, real carrier connections |
Verify Deployment
# Check Microcks pod
kubectl -n staqr-dev get pods -l app=microcks
# Check service
kubectl -n staqr-dev get svc -l app=microcks
# Check ingress
kubectl -n staqr-dev get ingress -l app=microcks
View Logs
# Microcks application logs
kubectl -n staqr-dev logs -l app=microcks -f
# Seed job logs (mock imports)
kubectl -n staqr-dev logs -l job-name=staqr-dev-seed-mocks
Health Monitoring
Health Endpoint
# Internal (from within cluster)
kubectl -n staqr-dev exec -it deploy/staqr-api -- \
curl http://staqr-dev-microcks:8080/api/health
# External (via ingress)
curl https://mocks.go.prvidr.io/api/health
Expected response:
{"status": "UP"}
Liveness/Readiness Probes
The Helm chart configures probes automatically:
livenessProbe:
httpGet:
path: /api/health
port: 8080
initialDelaySeconds: 60
periodSeconds: 10
readinessProbe:
httpGet:
path: /api/health
port: 8080
initialDelaySeconds: 30
periodSeconds: 5
Common Operations
Import Mock Definition
# Copy WSDL into cluster
kubectl -n staqr-dev cp mocks/microcks/import/optus-wsg-9.2.wsdl \
staqr-dev-microcks-0:/tmp/
# Import via API
kubectl -n staqr-dev exec -it staqr-dev-microcks-0 -- \
curl -X POST http://localhost:8080/api/artifact/upload \
-F "file=@/tmp/optus-wsg-9.2.wsdl"
List Imported Services
kubectl -n staqr-dev exec -it deploy/staqr-api -- \
curl -s http://staqr-dev-microcks:8080/api/services | jq '.[].name'
View Invocations (Request Logs)
kubectl -n staqr-dev exec -it deploy/staqr-api -- \
curl -s "http://staqr-dev-microcks:8080/api/invocations/WsgServiceOrderService/9.2?page=0&size=10" | jq
Clear Mock Data
# Delete and recreate pod (loses imported mocks)
kubectl -n staqr-dev delete pod -l app=microcks
# Seed job will re-import mocks on pod startup
Troubleshooting
Microcks Pod Not Starting
# Check pod events
kubectl -n staqr-dev describe pod -l app=microcks
# Common issues:
# - PVC not bound (storage class unavailable)
# - Image pull failure (registry access)
# - Resource limits too low
Mock Returns 404
# Check if service is imported
kubectl -n staqr-dev exec -it deploy/staqr-api -- \
curl http://staqr-dev-microcks:8080/api/services | jq '.[].name'
# Check exact endpoint path
kubectl -n staqr-dev exec -it deploy/staqr-api -- \
curl http://staqr-dev-microcks:8080/api/services | jq '.[].operations[].resourcePaths'
# Re-run seed job
kubectl -n staqr-dev delete job staqr-dev-seed-mocks
# ArgoCD will recreate it
Connection Timeout to Microcks
# Verify service is reachable
kubectl -n staqr-dev exec -it deploy/staqr-api -- \
nc -zv staqr-dev-microcks 8080
# Check network policy
kubectl -n staqr-dev get networkpolicy
# Check service endpoints
kubectl -n staqr-dev get endpoints staqr-dev-microcks
SOAP Request Not Matching
Ensure:
-
SOAPAction header matches WSDL operation:
curl -H "SOAPAction: SubmitServiceOrder" ... -
XML namespace matches WSDL targetNamespace:
<soapenv:Envelope xmlns:wsg="http://optus.com.au/wsg/9.2"> -
Request validates against XSD schema (Microcks validates by default)
Slow Startup
Microcks with embedded MongoDB takes 60-90 seconds to start. The Helm chart accounts for this:
startupProbe:
httpGet:
path: /api/health
port: 8080
failureThreshold: 30
periodSeconds: 5 # 150 seconds total
Scaling Considerations
Single Replica Only
Microcks with embedded MongoDB (uber profile) does not support horizontal scaling:
replicaCount: 1 # Do not increase
For high-availability requirements, use Microcks with external MongoDB (not recommended for mock services).
Resource Limits
Recommended resources for development:
resources:
limits:
cpu: "1"
memory: 1Gi
requests:
cpu: 500m
memory: 512Mi
Backup and Recovery
Export Mock Configurations
# Export all services
kubectl -n staqr-dev exec -it staqr-dev-microcks-0 -- \
curl http://localhost:8080/api/services/export > microcks-backup.json
Restore After Pod Replacement
The Helm chart's seed job (job-seed-mocks.yaml) handles this automatically by:
- Running as post-install/post-upgrade hook
- Importing all WSDL/OpenAPI files from
/mocks/
If manual restore is needed:
# Re-import backup
kubectl -n staqr-dev cp microcks-backup.json staqr-dev-microcks-0:/tmp/
kubectl -n staqr-dev exec -it staqr-dev-microcks-0 -- \
curl -X POST http://localhost:8080/api/artifact/upload \
-F "file=@/tmp/microcks-backup.json"
Metrics and Alerting
Prometheus Metrics
Microcks exposes metrics at /actuator/prometheus:
# ServiceMonitor (if using Prometheus Operator)
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: microcks
spec:
selector:
matchLabels:
app: microcks
endpoints:
- port: http
path: /actuator/prometheus
Suggested Alerts
# Microcks down
- alert: MicrocksDown
expr: up{job="microcks"} == 0
for: 5m
labels:
severity: warning
annotations:
summary: "Microcks mock service is down"
# High error rate
- alert: MicrocksHighErrorRate
expr: rate(http_server_requests_seconds_count{status=~"5..",app="microcks"}[5m]) > 0.1
for: 10m
labels:
severity: warning
Security Considerations
- No authentication in dev: Microcks runs with
KEYCLOAK_ENABLED=falsefor convenience - Internal access only: Service type is ClusterIP (not exposed externally except via ingress)
- Ingress protection: Consider IP allowlisting for admin UI access
- No sensitive data: Mock responses should not contain real customer data