I used this project to setup a local kubernetes cluster with two pods. Each pod contains a container with a Node.js application:
- nodeserver which exposes a simple server listening on the 1337
- nodeclient which exposes an HTTP server on the 8081 with 2 endpoints:
/
=> you can use it to get the homepage (to test mounted volumes, seemake mount
)/connect.html
=> you can use it to make a client connect to the server living in the other pod (nodeserver) via DNS service discovery
make mount
make create
- Get the nodeclient HTTP server address by doing
minikube service nodeclient --url
- Call the nodeclient HTTP server homepage (see bullet 3 above, e.g.
http://192.168.99.100:31144
) to test your mounted volume- you can make some changes to the
website/index.html
file and reload the page to see if it works
- you can make some changes to the
- Call the nodeclient
/connect.html
endpoint to test if the DNS service discovery works (e.g.http://192.168.99.100:31144/connect.html
)
make create
make local
make mount
make delete
minikube service nodeclient --url
kubectl logs POD_NAME -c nodeclient
To get the POD_NAME do kubectl get pod
.
kubectl exec -it POD_NAME -c nodeclient -- /bin/bash
To get the POD_NAME do kubectl get pod
.
- Delete any previous nodeclient deployment and service
kubectl delete deployment,svc nodeclient
- Create the nodeclient deployment and specify which port you want to expose
- Add
--dry-run -o yaml > deployment.yaml
to create conf file kubectl run nodeclient --image=nodeclient:dev-latest --port=8081
- Add
- Expose the previously created deployment
- Add
--dry-run -o yaml > svc.yaml
to create conf file kubectl expose deployment nodeclient --type=NodePort
- Add