This project implements simple logic of Hotel services. User is able to login/register, edit/delete account, create/edit/delete bookings. The project was implemented to suit Kubernetes deployment. The project can as well be executed with docker-compose on 7ae4087 commit and can be executed as plain Spring Boot services on e30e68d commit.
Note: Eureka discovery service is included only in docker and plain spring boot versions. In the latest commit with k8s deployment Eureka is excluded (not needed). Note: client service is deployed neither in k8s nor in docker compose.
- Start minikube
- Apply all the files present in
/hotel/k8sdirectory.
Note: it is preferable to deploy the
configandsecretfiles first, thenpostgres, so the spring boot applications will not deploy faster then their respective databases.
- Check that all the pods are in
Runningstate without any errors.
Note:
roomdatabase must be populated manually with sql. Below is tutorial on how to do it.
- As soon as the
pg-room-...pod is deployed, execute the following commandkubectl exec -it <pod-name> -- bash, where instead of<pod-name>you should put name of the pod (this can be achieved withkubectl get podscommand). - Next, update packages with command
apt-get updateand install sudo with commandapt-get install sudo. - Next, execute command
sudo -i -u postgresto switch topostgresuser. - Next, execute
psqlcommand to connect to the postgres, after that execute\lto list all the databases and verify thatroomsdatabase is present. - Next, execute
\c roomsto switch to the database. - The last step is to execute some dump data for testing:
insert into rooms (id, description, room_number, type, price, capacity, is_available)
values
(1, 'description', '1A', 'ORDINARY', 25.0, 2, true),
(2, 'description', '2A', 'ORDINARY', 25.0, 2, true),
(3, 'description', '3A', 'ORDINARY', 25.0, 2, true),
(4, 'description', '4A', 'VIP', 50.0, 4, true),
(5, 'description', '5A', 'VIP', 50.0, 4, true),
(6, 'description', '6A', 'LUXURY', 100.0, 6, true);
- To exit postgres, use
\q, to exit postgres user and postgres container useexit.
- Next, as soon as api-gateway pod is deployed and is in
Runningstate, execute commandminikube service api-gateway-svc. This command would tunnel the connection onto new port, which will be printed in the console. Copy this port as it will be needed in later steps. - Open client-service directory.
- Navigate to
/src/index.jsfile. - Change port in line
axios.defaults.baseURL = "http://localhost:<host>"instead of<host>. - Run
npm start.
Note: to execute this command,
node.jsshould be installed to your system. More information can be found here.
- Naviagate to
localhost:3000. - If everything was correct, the page should load the home page with 6 rooms.
This app is built with support of Spring Boot frameworks, main dependencies are SpringJpa, SpringCloud, SpringWebFlux, Resilience4J, SpringEureka (not used in k8s deployment), PostgreSQL. The overall structure consists of:
- API gateway that is the entrypoint for the backend part of the project.
- Hotel service that plays a role of an orchestration service that aggregates all the necessary data and manages other services.
- Auth service that mangages user login/register functionalities, it as well relates to the database
tokensto store user tokens to manage active sessions. - User/Room/Payment/Notification/Booking services are all similar in their implementation and functionality. All of them contain CRUD operations to manage the entities, and all of them have databases as well, i.e.
users,rooms,payments,notifications, andbookingsrespectively. - Client service is implemented with plain React.js and Axios.