In our Kubernetes 101 workshop, we ended up deploying our very basic application with Helm. So let’s start this workshop by also deploying with Helm, but our multi-container-application this time. 💪
For your convenience, we’ve already created the Helm charts alongside the demo app codebase, so you don’t have to copy & paste too much.
To get started, let’s first clone the repository by running
git clone https://git.bnerd.com/workshop-public/todo-app.git
on your machine - and please keep in mind our focus is on infrastructure and not so much on the apps themselves 😇
You will find two folders containing the source code for our frontend and our backend - and the relevant folder for this lab: infrastructure. It contains the Helm charts for both the backend and the frontend.
Install Backend
Before starting with the deployment, there are some minor updates you have to make within the values.yaml file in our Helm charts. Please add your namespace:
Done? Great. Then make sure you’re within the infrastructure/charts/backend directory and run
helm upgrade --install backend . -n <your namespace>
And there is our backend pod. When selecting the pod and clicking l, you could also see the notification from the app. If everything went well, you can see the app is up and running and connected to our database.
Install Frontend
Next, let’s deploy the frontend. As with the backend, we have to adapt the values.yaml file and add our namespace:
Ensure you are within the infrastructure/charts/frontend directory and run
helm upgrade --install frontend . -n <your namespace>
Open k9s again and have a look - your Pod is there and up and running. 🎉 Please check in k9s logs, if you can see the app notification.
We also deployed an ingress for both services, so we can now edit our local DNS entry so we are able to check backend and frontend in the browser.
We first need to find out the IP address our ingress is using. So open k9s, press : and type ingress into the search field. Look out for your namespace, where you will find the ingresses for both frontend and backend. The very first IP address under ADRESS is the one we need.
Please copy it, then run:
sudo vi /etc/hosts
in a separate terminal to open your etc/hosts file. Add your password, then press i to enter the vim insert mode. At the end of your file, please add:
<your IP address> bnerd-<your namespace>.todos
<your IP address> bnerd-<your namespace>.api
Press esc to exit the insert mode, then :wq to save and exit vim.
Lets try if everything works out :) Visit
http://bnerd-<your namespace>.todos (the frontend showing the tasks added already to the database)http://bnerd-<your namespace>.api (our backend providing the API).And here we go, our ToDo-App is deployed, reachable from outside the cluster and we can add and edit todos 🎉
So far so good. We have seen our application is working and available on the host we specified. But … We are still working and updating it manually. Not very Devopsy, right? So, in the next step, lets build our own image and deploy via a Gitlab Pipeline!
But before continuing, lets first clean our cluster up so we can start fresh. Please be careful and only delete the resources created in your namespace by using:
helm uninstall frontend -n <your namespace>
helm uninstall backend -n <your namespace>