Skip to content
This repository was archived by the owner on Jul 7, 2024. It is now read-only.

Latest commit

 

History

31 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ARCHIVED

Powerlibrary

Author MIT+ License

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.

How to use it

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.

  1. Build the docker images that we need. Inside of services/books/database we 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 .
  1. If you use minikube, load the images into the minikube vm. For postgres the command is as follow
minikube image load pl-books-postgres:13

Do the same for the other images.

  1. Go to services/books/frontend and execute the following command:
kubectl apply -f pl-frontend-ingress

which 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.

  1. Then execute:
kubectl apply -f pl-books-frontend-service.yaml -f pl-books-frontend-service

in order to setup the React frontend.

  1. In services/books/backend execute:
kubectl apply -f pl-books-pv -f pl-books-pvc -f pl-books-backend-service -f pl-books-backend-pod

to setup the books backend. We are finished with the books service, now lets do the same for the shelfs service.

  1. First of all, we have to build the images again. Go inside of services/shelfs/backend and 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.

  1. Now we can go inside of services/shelfs/backend and execute the following command:
kubectl apply -f pl-shelfs-pv -f pl-shelfs-pvc -f pl-shelfs-backend-service -f pl-shelfs-backend-pod

and the shelf service is set up!

  1. Use kubectl get ingress to retrieve the ip which you use for looking up the homepage of the app.

Results

Homepage

Forms

Note

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.

About

Example library implementation on Minikube with 2 microservices (REST API and GraphQL). Put your books into the shelf and see where you left them after you forgot the location!

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages