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.
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
- 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:
- Docker: https://docs.docker.com/engine/installation/
- Docker Compose: https://docs.docker.com/compose/install/
If you want to try this out within a Kubernetes environment this is all you need:
- Kubectl: https://kubernetes.io/docs/tasks/tools/install-kubectl/
- Minikube: https://kubernetes.io/docs/tasks/tools/install-minikube/
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
.
(OPTIONAL STEP; images have already been pushed to the docker hub public repository https://hub.docker.com/repository/docker/waleedakramkhann/hotelclient)
- Create an image for
client
and push it to dockerhub: 1.1. Move toclient
directorycd client/
1.2. Build the image with Dockerfiledocker build -t <hub-user>/hotelclient .
Note that we are insideclient
directory.<hub-user>/hotelclient
would be name of our image 1.3. You can check your newly built image usingdocker images
1.4. Push the images to Dockerhubdocker 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)
- Create an image for
server
and push it to dockerhub: 2.1. Move toserver
directorycd server/
2.2. Build the image with Dockerfiledocker build -t <hub-user>/hotelserver .
Note that we are insideserver
directory.<hub-user>/hotelserver
would be name of our image 2.3. You can check your newly built image usingdocker images
2.4. Push the images to Dockerhubdocker 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)
- Create an image for
database
and push it to dockerhub: 2.1. Move todatabase
directorycd database/
2.2. Build the image with Dockerfiledocker build -t <hub-user>/hoteldb .
Note that we are insidedatabase
directory.<hub-user>/hoteldb
would be name of our image 2.3. You can check your newly built image usingdocker images
2.4. Push the images to Dockerhubdocker push <hub-user>/hoteldb
-
Start the
minikube
viaminikube start
. -
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 runningkubectl get pods -n ingress-nginx
-
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 usingkubectl get secrets
-
Create all deployments and services using
kubectl apply -f k8s
-
Confirm that all pods are up and running using
kubectl get pods
-
Get the name ($POD) of MySQL pod using
kubectl get pod -l component=mysql -o name
-
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
-
Initialize the database using
kubectl -n default exec -i $POD -- mysql -u root -p$PASSWORD < ~HotelManagementSystem-Docker-K8s/database/init/01.sql
-
Get the IP address ($IP-ADDRESS) and port ($PORT) using
kubectl get ingress
-
After everything is up and running you can start using the app running on port
$IP-ADDRESS:$PORT
in browser of your choice.