Skip to content

Hotel Management System deployed using docker, k8s and shell scripting. Authors: Waleed Akram Khan & Abdullah Fawad

Notifications You must be signed in to change notification settings

waleedakramkhan/HotelManagementSystem-Docker-K8s

Repository files navigation

HotelManagementSystem-Docker-K8s

The project this repository contains is, in essence, a hotel management system. Tourism is an absolutely booming industry, and we plan to capitalize on that popularity and make the entire accommodation arrangement process of vacations and tours easier. The management system will serve as a database of hotels, one that a user can use to book hotels and rooms online and in general, plan their stays at hotels. The functionalities include booking rooms, checking in and checking out and dropping reviews after styas at various hotels. The main objective of the project was DevOps.

The implementation makes use of the following technologies:

  • NodeJS, used for the implementation of the backend and the server logic of the web application.
  • MySQL, as database to store records for the web applications.
  • Kubernetes, for container orchestration and ensuring high availability and scalability.
  • Docker, for creating, deploying and running the web application using containers.
  • Shell, for automating the creation and deployment of the web application.
  • ReactJS, used for handling the web application’s View layer and UI.

The project structure is as donated by the diagrams below:

Cloud

The database structure is as donated the ER diagram below;

ER

A few screenshots of the running system:

295

296

297

298

Directory Structure

Also present in directory_struct.txt . ├── client │   ├── Dockerfile │   ├── Dockerfile.dev │   ├── nginx │   │   └── default.conf │   ├── package.json │   ├── package-lock.json │   ├── public │   │   ├── favicon.ico │   │   ├── index.html │   │   ├── logo192.png │   │   ├── logo512.png │   │   ├── manifest.json │   │   └── robots.txt │   └── src │   ├── App.css │   ├── App.js │   ├── App.test.js │   ├── Components │   │   ├── bookroom.component.js │   │   ├── checkin.component.js │   │   ├── checkout.component.js │   │   ├── landing.component.js │   │   ├── login.component.js │   │   ├── review.component.js │   │   └── signup.component.js │   ├── Constants │   ├── index.css │   ├── index.js │   ├── logo.svg │   ├── reportWebVitals.js │   ├── resort.jpg │   └── setupTests.js ├── database │   ├── Dockerfile │   └── init │   └── 01.sql ├── deploy.sh ├── directory_struct.txt ├── docker-compose.yml ├── k8s │   ├── client-cluster-ip-service.yml │   ├── client-deployment.yml │   ├── database-persistent-volume-claim.yml │   ├── ingress-service.yml │   ├── mysql-cluster-ip-service.yml │   ├── mysql-deployment.yml │   ├── server-cluster-ip-service.yml │   └── server-deployment.yml ├── nginx │   ├── default.conf │   └── Dockerfile.dev ├── README.md └── server ├── Dockerfile ├── Dockerfile.dev ├── index.js ├── keys.js ├── package.json └── package-lock.json

11 directories, 49 files

Usage

Requirements

  • GNU Make (available in your package manager of preference)

If you wish to play with it without locally installing Postgres and Node you can take advantage of docker and docker-compose which would help you build the container images and setup a working environment for you:

If you want to try this out within a Kubernetes environment this is all you need:

Usage with Docker

Once docker and docker-compose are installed run docker-compose up --build.

This will trigger the pulling and building of the necessary images and will use docker-compose to setup the app and the MySQL containers.

Once the Postgres MySQL starts up (note that it may take a few minutes until it starts accepting connections the first time) it will automatically run the database migrations using the .sql scripts in init directory.

After everything is up and running you can start using the app running on port localhost:3050 in browser of your choice.

The MySQL database data directory is setup to be mounted in the data/db directory at the root of the project. In case you want to start afresh just issue rm -rf data.

Usage with Minikube + Kubernetes

(OPTIONAL STEP; images have already been pushed to the docker hub public repository https://hub.docker.com/repository/docker/waleedakramkhann/hotelclient)

  1. Create an image for client and push it to dockerhub: 1.1. Move to client directory cd client/ 1.2. Build the image with Dockerfile docker build -t <hub-user>/hotelclient . Note that we are inside client directory. <hub-user>/hotelclient would be name of our image 1.3. You can check your newly built image using docker images 1.4. Push the images to Dockerhub docker push <hub-user>/hotelclient

(OPTIONAL STEP; images have already been pushed to the docker hub public repository https://hub.docker.com/repository/docker/waleedakramkhann/hotelserver)

  1. Create an image for server and push it to dockerhub: 2.1. Move to server directory cd server/ 2.2. Build the image with Dockerfile docker build -t <hub-user>/hotelserver . Note that we are inside server directory. <hub-user>/hotelserver would be name of our image 2.3. You can check your newly built image using docker images 2.4. Push the images to Dockerhub docker push <hub-user>/hotelserver

(OPTIONAL STEP; images have already been pushed to the docker hub public repository https://hub.docker.com/repository/docker/waleedakramkhann/hoteldb)

  1. Create an image for database and push it to dockerhub: 2.1. Move to database directory cd database/ 2.2. Build the image with Dockerfile docker build -t <hub-user>/hoteldb . Note that we are inside database directory. <hub-user>/hoteldb would be name of our image 2.3. You can check your newly built image using docker images 2.4. Push the images to Dockerhub docker push <hub-user>/hoteldb

You can either follow these steps or run bash deploy.sh

  1. Start the minikube via minikube start.

  2. Enable the Ingress controller: 4.1. Enable the NGINX Ingress controller using minikube addons enable ingress 4.2. Verify that the NGINX Ingress controller is running kubectl get pods -n ingress-nginx image

  3. Generate an Opqaue Secret to hold password for MySQL database server 5.1 Generate an opaque secret using kubectl create secret generic mysqlpassword --from-literal MYSQLPASSWORD=<your-password> 5.2 Verify that the secret has been generated using kubectl get secrets

  4. Create all deployments and services using kubectl apply -f k8s

  5. Confirm that all pods are up and running using kubectl get pods image

  6. Get the name ($POD) of MySQL pod using kubectl get pod -l component=mysql -o name

  7. Get the password ($PASSWORD) for MySQL database server using kubectl get secrets mysqlpassword -grep MYSQLPASSWORD | grep -v f:s | awk -F '"' '{print$4}' | base64 --decode

  8. Initialize the database using kubectl -n default exec -i $POD -- mysql -u root -p$PASSWORD < ~HotelManagementSystem-Docker-K8s/database/init/01.sql

  9. Get the IP address ($IP-ADDRESS) and port ($PORT) using kubectl get ingress image

  10. After everything is up and running you can start using the app running on port $IP-ADDRESS:$PORT in browser of your choice.

About

Hotel Management System deployed using docker, k8s and shell scripting. Authors: Waleed Akram Khan & Abdullah Fawad

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published