Running our application on Kubernetes
- Introduction
- Is this working?
- Connecting containers together
- Is this working yet?
- Exposing services for external access
- Accessing the web UI
Introduction
- We can now deploy our code (as well as a redis instance)
Exercise
Deploy
redis:kubectl create deployment redis --image=redisDeploy everything else:
for SERVICE in hasher rng webui worker; do kubectl create deployment $SERVICE --image=$REGISTRY/$SERVICE:$TAG done
Is this working?
After waiting for the deployment to complete, let's look at the logs!
(Hint: use
kubectl get deploy -wto watch deployment events)
Exercise
Look at some logs:
kubectl logs deploy/rng kubectl logs deploy/worker
🤔 rng is fine ... But not worker.
💡 Oh right! We forgot to expose.
Connecting containers together
Three deployments need to be reachable by others:
hasher,redis,rngworkerdoesn't need to be exposedwebuiwill be dealt with later
Exercise
Expose each deployment, specifying the right port:
kubectl expose deployment redis --port 6379 kubectl expose deployment rng --port 80 kubectl expose deployment hasher --port 80
Is this working yet?
- The
workerhas an infinite loop, that retries 10 seconds after an error
Exercise
Stream the worker's logs:
kubectl logs deploy/worker --follow(Give it about 10 seconds to recover)
We should now see the worker, well, working happily.
Exposing services for external access
Now we would like to access the Web UI
We will expose it with a
NodePort(just like we did for the registry)
Exercise
Create a
NodePortservice for the Web UI:kubectl expose deploy/webui --type=NodePort --port=80Check the port that was allocated:
kubectl get svc
Accessing the web UI
- We can now connect to any node, on the allocated node port, to view the web UI
Exercise
- Open the web UI in your browser (http://node-ip-address:3xxxx/)
Yes, this may take a little while to update. (Narrator: it was DNS.)
Alright, we're back to where we started, when we were running on a single node!