ibrahima1289 / kura-database-assignment

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Database Assignment with MongoDB

1. Goal:

The goal for this assignment is to deploy an application locally (local computer is the host) using kubernetes.
The application has a database. The user will interact with the front-end in order to input or read data stored in the database.
The database is set up so that the front-end authenticate before accessing the back-end (wich is the database in this case).

2. Architecture:

3. Software tools used:

We avoid using a cloud provider for the deployment for cost purposes.
This is not used in a production environment.

4. Procedure:

Note: Avoid pasting the $ sign; it is not part of the commands. The sign shows up when you use Linux.

  1. Create a cluster with a loadbalancer with port mapping “8080:8081”
k3d cluster create mycluster -p "8080:8081@loadbalancer"

You should see:

  • port 8080 is for the access to the front-end.
  • port 8081 is for the access to the application
  • port 27017 is the port open in order to access the database
  1. Encode the username and password and put it in the secret.yaml file.
    In the command line, type this:
$ echo -n mongo-root-username | base64

Output: bW9uZ28tcm9vdC11c2VybmFtZQ==

Then, do the same for the password:

$ echo -n mongo-root-password | base64

Output: bW9uZ28tcm9vdC1wYXNzd29yZA==

  1. Create the yaml files in your working directory.

  1. Now, run these commands in the order they are given.
$ kubectl apply -f secret.yaml

$ kubectl apply -f mongo-deploy.yaml

$ kubectl apply -f config_map.yaml

$ kubectl apply -f mongo-express.yaml

  1. Verfy that the pods are running:
$ kubectl get pod

  1. Verify that the app is working by typing to the url:
localhost:8080

Source:

About