MockServer is available as Helm chart so it can be easily installed in Kubernetes.

To install the chart with:

  • release name: mockserver
  • namespace: mockserver
  • configuration: values (see values.yaml for values definitions)

Remotely using www.mock-server.com as a chart repo:

helm upgrade --install --namespace mockserver mockserver http://www.mock-server.com/mockserver-5.5.0.tgz

Or if you have helm chart source folder (i.e. you have the repository cloned):

helm upgrade --install --values helm/mockserver/values.yaml --namespace mockserver mockserver helm/mockserver

To wait until the deployment is complete run:

kubectl rollout status deployments mockserver -n mockserver

To check the status of the deployment without waiting, run the following command and confirm the mockserver has the Running status:

kubectl get po -l release=mockserver -n mockserver

To view the logs:

kubectl logs $(kubectl get po -l release=mockserver -n mockserver | awk '{if(NR==2)print $1}') -n mockserver

MockServer will know be deployed a DNS inside kubernetes cluster, of mockserver.<namespace>.svc.cluster.local, i.e. mockserver.mockserver.svc.cluster.local

To retrieve MockServer address outside kubernetes cluster:

export NODE_PORT=$(kubectl get --namespace mockserver -o jsonpath="{.spec.ports[0].nodePort}" services mockserver)
export NODE_IP=$(kubectl get nodes --namespace mockserver -o jsonpath="{.items[0].status.addresses[0].address}")
export MOCKSERVER_HOST=$NODE_IP:$NODE_PORT
echo http://$MOCKSERVER_HOST

To remove the MockServer deployment from Kubernetes:

helm delete mockserver --purge