Scenario: An example library use-case implementation based on a full-stack: React with Typescript as frontend, Golang as backend and PostgreSQL as a database in a microservice architecture. This app works with two entities or services in this case, the shelf service and the book service, the book service is managing the books and the shelf service the shelfs in which books can be put. It should be also possible to display the books and to see in which shelf they are, so that you never lose your book again in your tremendously large library at home.
You basically only need docker and kubernetes, e.g. minikube. Note that you also need an ingress controler. With docker you will build the images and with kubectl you will apply the yaml files in your kubernetes cluster. In this repo you find a folder services which contains two folders: books and shelfs. These are the services which we will deploy.
- Build the docker images that we need. Inside of
services/books/databasewe have to build the database image first in order to use it in the books backend pod:
docker build -t pl-books-postgres:13 .Inside of services/books/backend we have to build the backend docker image with:
docker build -t pl-books-v1 .Then go to services/books/frontend in order to build the frontend image:
docker build -t pl-books-frontend-v1 .- If you use minikube, load the images into the minikube vm. For postgres the command is as follow
minikube image load pl-books-postgres:13Do the same for the other images.
- Go to
services/books/frontendand execute the following command:
kubectl apply -f pl-frontend-ingresswhich will start an ingress server which will route the external traffic towards the appropriate backend server and also the frontend will be served to the client in that way.
- Then execute:
kubectl apply -f pl-books-frontend-service.yaml -f pl-books-frontend-servicein order to setup the React frontend.
- In
services/books/backendexecute:
kubectl apply -f pl-books-pv -f pl-books-pvc -f pl-books-backend-service -f pl-books-backend-podto setup the books backend. We are finished with the books service, now lets do the same for the shelfs service.
- First of all, we have to build the images again. Go inside of
services/shelfs/backendand do
docker build -t pl-shelfs .and inside of services/shelfs/database:
docker build -t pl-shelfs-postgres:13 .If you use minikube, do not forget to load the images as we did in step 2.
- Now we can go inside of
services/shelfs/backendand execute the following command:
kubectl apply -f pl-shelfs-pv -f pl-shelfs-pvc -f pl-shelfs-backend-service -f pl-shelfs-backend-podand the shelf service is set up!
- Use
kubectl get ingressto retrieve the ip which you use for looking up the homepage of the app.
When using minikube it could be that your data inside of the databases get lost. A fix for that is not available for now but will perhaps come in the future.




