Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
Signed-off-by: Your Name <[email protected]>
  • Loading branch information
Your Name committed Jan 6, 2024
1 parent 75620a3 commit dbf8431
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 73 deletions.
85 changes: 12 additions & 73 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Introduction

This project runs a nodejs application and uses mongodb as database. It has an API performs the CRUD operations by interacting with database. The creates a product , updates a product, get a single and all products and deletes a product.

Look at the [file](models/productModels.js) to know about schema of a product.

# Local Setup

Follow the following steps if you want to run this app on your local machine.
Expand All @@ -26,6 +30,7 @@ Now go to browser and type `localhost:3000` or `localhost:3000/blog`

# Running the tests

Follow the [README](tests/README.md) of tests if you want to know about tests.
Use `npm test` to run the test.


Expand All @@ -39,85 +44,19 @@ Like this

# Docker


For docker follow this [README.md](docker/README.md).

# Kubernetes

For kubernetes follow this [README.md](kubernetes/README.md).

# Vagrant and Ansible

# Istio

## Pre-requisites
Make sure the cluster is running.
Install istio using this [link](https://istio.io/latest/docs/setup/getting-started/#install).

## Simple deployment

```
kubectl create ns node-mongo-istio
kubectl label namespace node-mongo-istio istio-injection=enabled
cd istio/simple
kubectl apply -f mongo-deploy.yaml -n node-mongo-istio
kubectl apply -f nodejsapp-deploy.yaml -n node-mongo-istio
kubectl apply -f mongo-service.yaml -n node-mongo-istio
kubectl apply -f node-service.yaml -n node-mongo-istio
kubectl apply -f gateway-nodejs.yaml -n node-mongo-istio
```

Verify that the service has been created using

```
azureuser@istio-practice:~$ kubectl -n istio-system get service istio-ingressgateway
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S)
AGE
istio-ingressgateway LoadBalancer 10.96.160.94 <pending> 15021:31031/TCP,80:32281/TCP,443:30942/TCP,31400:31668/TCP,15443:30901/TCP 43m
```
For vagrant and ansible follow this [README.md](iac/README.md).

You can now request the following

```
INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}')
```
Get the IP using `MINIKUBE_IP=$(minikube ip)`

Now you can do curl requests.
```
azureuser@istio-practice:~$ curl http://$MINIKUBE_IP:$INGRESS_PORT
Hello NODE API
```

You can even use the API externally.

In separate terminal run the following

```
kubectl -n istio-system port-forward service/istio-ingressgateway 8080:80
```

In another terminal use `curl http://localhost:8080` .

## Canary Rollout

```
kubectl create ns node-mongo-istio
kubectl label namespace node-mongo-istio istio-injection=enabled
cd istio/request_routing
kubectl apply -f mongo-deploy.yaml -n node-mongo-istio
kubectl apply -f nodejs-dev-deploy.yaml -n node-mongo-istio
kubectl apply -f nodejs-prod-deploy.yaml -n node-mongo-istio
kubectl apply -f mongo-service.yaml -n node-mongo-istio
kubectl apply -f nodejs-service.yaml -n node-mongo-istio
kubectl apply -f destination-rule.yaml -n node-mongo-istio
kubectl apply -f virtual-service.yaml -n node-mongo-istio
```
# Istio
For istio follow this [README.md](istio/README.md).


# Monitoring
For monitoring follow this [README.md](monitoring/README.md).
100 changes: 100 additions & 0 deletions istio/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
## Pre-requisites
Make sure the cluster is running.

If not start the cluster using
```
minikube start --memory 12000 --cpus 2
```

Install istio using this [link](https://istio.io/latest/docs/setup/getting-started).

We can use istio using two ways one is simple deployment and other is canary rollout.


In simple we let every other request pass through istio and then through kubernetes.


In canaray rollout we have two deployments one is production(prod) and other is development.
We pass the 20 percent of the network traffic to development and 80 percent to prod.
Later we can increase the traffic steadily and fully route the traffic to prod.

## Simple deployment

Create namespaces.
```
kubectl create ns node-mongo-istio
kubectl label namespace node-mongo-istio istio-injection=enabled
```

Now fo to simple directory `cd simple`

Now type the following commands.

```
kubectl apply -f mongo-deploy.yaml -n node-mongo-istio
kubectl apply -f nodejsapp-deploy.yaml -n node-mongo-istio
kubectl apply -f mongo-service.yaml -n node-mongo-istio
kubectl apply -f node-service.yaml -n node-mongo-istio
kubectl apply -f gateway-nodejs.yaml -n node-mongo-istio
```

Verify that the service has been created using

```
azureuser@istio-practice:~$ kubectl -n istio-system get service istio-ingressgateway
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S)
AGE
istio-ingressgateway LoadBalancer 10.96.160.94 <pending> 15021:31031/TCP,80:32281/TCP,443:30942/TCP,31400:31668/TCP,15443:30901/TCP 43m
```

You can now request the following

```
INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}')
```
Get the IP using `MINIKUBE_IP=$(minikube ip)`

Now you can do curl requests.
```
azureuser@istio-practice:~$ curl http://$MINIKUBE_IP:$INGRESS_PORT
Hello NODE API
```

You can even use the API externally.

In separate terminal run the following

```
kubectl -n istio-system port-forward service/istio-ingressgateway 8080:80
```

In another terminal use `curl http://localhost:8080` .


## Canary Rollout

Create namespaces.
```
kubectl create ns node-mongo-istio
kubectl label namespace node-mongo-istio istio-injection=enabled
```

Now do
`cd request_routing`

Now apply the following
```
kubectl apply -f mongo-deploy.yaml -n node-mongo-istio
kubectl apply -f nodejs-dev-deploy.yaml -n node-mongo-istio
kubectl apply -f nodejs-prod-deploy.yaml -n node-mongo-istio
kubectl apply -f mongo-service.yaml -n node-mongo-istio
kubectl apply -f nodejs-service.yaml -n node-mongo-istio
kubectl apply -f destination-rule.yaml -n node-mongo-istio
kubectl apply -f virtual-service.yaml -n node-mongo-istio
```


25 changes: 25 additions & 0 deletions monitoring/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Monitoring using prometheus and grafana

Make sure you have installed docker and docker compose follow the docker [README.md](../docker/README.md)

Now do
`docker-compose up`

You can stats using
`curl -sX GET http://localhost:3001`

or better open in browser like this.

Use `http://localhost:3001`.

![alt text](images/grafana.png)

Note if you are doing this in azure apply the following inbound rule like this.
![alt text](images/azure.png)

Use the following config.

![alt text](images/rule.png)



Binary file added monitoring/images/azure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added monitoring/images/grafana.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added monitoring/images/rule.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Here database connection test, server tests and scema check tests are there in dbclient.js , server.js and models.js respectively.

0 comments on commit dbf8431

Please sign in to comment.