Run nginx:
# kubectl run web --image=nginx
kubectl create deployment web --image=nginx
Expose nginx on the internet:
kubectl expose deploy/web --type=NodePort --port=80
Get the nginx web page:
# Get pod ID
POD_ID=$(kubectl get pods -l app=web -o json | jq -r '.items[0].metadata.name')
# Get public IP of pod (works because nginx uses ubuntu)
kubectl exec -it $POD_ID -- apt-get update
kubectl exec -it $POD_ID -- apt-get install -y curl
PUBLIC_IP=$(kubectl exec -it $POD_ID -- curl ifconfig.me)
# Get nodePort
PUBLIC_PORT=$(kubectl get svc web -o json | jq -r '.spec.ports[0].nodePort')
echo "Public IP and port found... $PUBLIC_IP:$PUBLIC_PORT"
# Get web page
curl $PUBLIC_IP:$PUBLIC_PORT
Run flaskdemo:
kubectl create deployment flaskdemo --image=skipperkongen/flaskdemo:latest
Expose flaskdemo on the internet:
kubectl expose deploy/flaskdemo --type=NodePort --port=5000