Skip to content

Commit

Permalink
Added Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajdip019 committed Oct 27, 2024
1 parent bfa80fd commit 2483d09
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 16 deletions.
72 changes: 68 additions & 4 deletions docs/local-setup/readme.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,75 @@
## Local Setup
## Local Setup Kubernets

### Step 1: Pre-requisites

- [Rust Basics](https://doc.rust-lang.org/book/)
- [Cargo (Rust package manager)](https://doc.rust-lang.org/cargo/getting-started/installation.html)
- [Docker (For containerization)](https://docs.docker.com/get-docker/)
- [MongoDB Compass (For Visualising DB with GUI)](https://www.mongodb.com/try/download/compass)
- [Kubernets](https://kubernetes.io/)
- [Minikube (For Kubernets)](https://minikube.sigs.k8s.io/docs/start/?arch=/macos/arm64/stable/binary+download)

### Step 2: Environment Variables

Run this command to start setting up the environment👇
```
make setup
```
It will automatically start asking you all the required environment variables it needs and automatically create the environment variables it can.

#### Here are some of the variables you need and here's how to get them 👇
You can generate `SERVER_KEK` by running the command below from the root of your project. ( Make sure you have cargo installed )

```
cargo run --bin create_kek
```
For testing purposes only you can use this SERVER_KEK as well: **9628177f62a03f5db4742273b915bf66.a21a897aa750**

SMTP servers require authentication to ensure that only authorized users can send emails. For generating `EMAIL_PASSWORD`, Visit this [link](https://support.google.com/mail/thread/205453566/how-to-generate-an-app-password?hl=en).

`SMTP_DOMAIN = smtp.gmail.com` as we are using GMAIL as a Mail Provider.

For MongoDB username and password, you can use anything you want. But remember you need the same username and password for Mongo Compass mentioned in step 4.

### Step 3: Spinning up kubernetes

Now it's time to spin up the kubernets cluster by running this following command (Make sure you have Docker installed)

```
make flexauth-up-k8s
```

This command will build all your local docker files using `skaffold` and then spin up the kubernets cluster. Once the pods are up and running it will start streamung the flexauth server logs to the terminal You can see the kubernetes deployment configs in the `k8s/local` file.

**Tunneling** : If you want to tunnel the API and the Mongo express server make sure to run below command there so that you can reach the services by from your localhost.
```
minikube tunnel
```

Then you will be able to see your servers are running at the following addresses:

**Flexauth server address:** `http://127.0.0.1:8080`

**Mongo-express address:** `http://127.0.0.1:8081`

Once done to shut down the cluster we need to run the command below
```
flexauth-down-k8s
```

**Note:** Killing the terminal that serving logs or minikube server doesn't make the kubernetes cluser down. So, make sure to run the command.

Congrats, Your Local Setup is done successfully.


## Local Setup Docker

### Step 1: Pre-requisites

- [Rust Basics](https://doc.rust-lang.org/book/)
- [Cargo (Rust package manager)](https://doc.rust-lang.org/cargo/getting-started/installation.html)
- [Docker (For containerization)](https://docs.docker.com/get-docker/)
- [MongoDB Compass (For Visualizing DB with GUI)](https://www.mongodb.com/try/download/compass)

### Step 2: Environment Variables

Expand Down Expand Up @@ -35,12 +99,12 @@ Now it's time to run the docker container by running this following command (Mak

If you want to build the containers and then want to spin them up use this command 👇
```
make build-run-server
flexauth-build-up-docker
```

Otherwise, you can use
```
make run-server
make flexauth-up-docker
```

This command will start the container and watch the /src folder for any changes. If there are any modifications to the content inside /src, the container will automatically hot reload to reflect those changes.
Expand Down
12 changes: 0 additions & 12 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,6 @@ flexauth-address-k8s:
@echo "Flexauth server address: http://127.0.0.1:8080"
@echo "Mongo-express address: http://127.0.0.1:8081"

# Close minikube tunnel first check if it's running
.PHONY: flexauth-down-tunnel
down-tunnel:
@echo "Checking if Minikube tunnel is running..."
@if pgrep -f "minikube tunnel" > /dev/null; then \
echo "Minikube tunnel is running. Closing it now..."; \
pkill -f "minikube tunnel"; \
echo "Minikube tunnel closed."; \
else \
echo "Minikube tunnel is not running."; \
fi

# Delete all the resources
.PHONY: flexauth-down-k8s
down-k8s:
Expand Down

0 comments on commit 2483d09

Please sign in to comment.