export DOCKER_ID_USER="username"
docker pull $DOCKER_ID_USER/hello_node
docker run -d -p 8080:8080 $DOCKER_ID_USER/hello_node
docker ps
to see what's running (node the CONTAINER ID)- open http://localhost:8080/
docker stop <CONTAINER ID>
docker login
docker build -t $DOCKER_ID_USER/hello_node .
docker push $DOCKER_ID_USER/hello_node
kubectl run hello-node --image=index.docker.io/$DOCKER_ID_USER/hello_node --port=8080
- Check the deployment is there with
kubectl get deployments
- Check the pods are up with
kubectl get pods
- Check it's running properly before exposure with
kubectl exec -ti hello-node-7ddff5778f-nt2g6 curl localhost:8080
- Expose with
kubectl expose deployment/hello-node --type="NodePort" --port=8080
- Check with
kubectl get services
- Get a full description with
kubectl describe services/hello-node
- Pull the NodePort into an environment variable for easier use with
export NODE_PORT=$(kubectl get services/hello-node -o go-template='{{(index .spec.ports 0).nodePort}}') && echo NODE_PORT=$NODE_PORT
- Open the app in a web browser: http://<IP_OF_ANY_NODE>:<NODE_PORT>/
- Clean up with
kubectl delete service,deployment hello-node
kubectl apply -f kubernetes.yaml
(apply is impdepotent so use instead of create which is just for creating). Using 1 file so the service is created first which causes the container's env vars to contain service info plus scheduling should spread them between hosts.
The interactive tutorials on kubernetes.io are pretty good.