A simple Hello World Node.js app deployed with Kubernetes.
- Start minikube
minikube start
- Point shell to minikube's Docker daemon
eval $(minikube docker-env)
- Build Docker image
docker build -t node-app .
- Create deployment
kubectl apply -f deployments/deployment.yaml
- Verify that two replica pods have been created
kubectl get pod
# should return something similar to:
#
# NAME READY STATUS RESTARTS AGE
# node-app-deployment-799f65478b-9drrm 1/1 Running 0 7s
# node-app-deployment-799f65478b-j4vwb 1/1 Running 0 7s
- Create service
kubectl apply -f deployments/service.yaml
- Verify that service has been created
kubectl get service
# should return something similar to:
#
# NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
# kubernetes ClusterIP <ip> <none> 443/TCP 65m
# node-app-service LoadBalancer <ip> <pending> 3000:31000/TCP 33m
- Test service
minikube service node-app-service --url
# using a seperate terminal instance
curl http://<external_service_ip>:31000 # returns "Hello world!"