Skip to content

Commit

Permalink
docs: add docs for GKE deployment
Browse files Browse the repository at this point in the history
deployment via docker-compose and scaling
  • Loading branch information
NishaSharma14 committed Aug 31, 2023
1 parent 87887fc commit d04d88c
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default defineConfig({
items: [
//{ text: 'Public API', link: '/public-api' },
{ text: 'Docker', link: '/docker' },
{ text: 'Cluster Deployment (K8S)', link: '/cluster-deployment' }
{ text: 'Cluster Deployment (K8S)', link: '/cluster-deployment' },
]
},
{
Expand Down
72 changes: 71 additions & 1 deletion docs/cluster-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,79 @@ helm uninstall myrelease
This will delete all resources created by the chart, including pods, services, and any other Kubernetes objects.


# Deployment to Google Kubernetes Engine(GKE) using Helm.
This documentation will guide you through the process of deploying the CPM application in [Google Kubernetes Engine (GKE)](https://cloud.google.com/kubernetes-engine) using [Helm](https://helm.sh/docs/). Here we provide a step-by-step instructions to help you set up your environment, install Helm, and dpeloy the CPM application in the Google Kubernetes Cluster.

## Prerequisites
Before you begin, ensure you have the following prerequisites in place:
* Google Cloud Platform (GCP) Account: You need a GCP account to create a GKE cluster and use other GCP services.
* In the Google Cloud console, on the project selector page, select or [create a Google Cloud project](https://cloud.google.com/resource-manager/docs/creating-managing-projects).
* Enable the Compute Engine, Artifact Registry, and Google Kubernetes Engine APIs.
* Activate Cloud Shell
* Go to [Google Cloud Console](https://console.cloud.google.com/)
* Click on the 'Activate Cloud Shell' button located at the top of the Google Cloud console window.

### Step 1: Create a GKE Cluster
A GKE cluster consists of a pool of Compute Engine VM instances running [Kubernetes](https://kubernetes.io/), the open source cluster orchestration system that powers GKE.
1. Navigate to [Google Kubernetes Engine](https://console.cloud.google.com/kubernetes) page in Google Cloud console.
2. Click on the Create icon.
3. You can choose between `Autopilot` or `Standard` and click on `Configure`. But as the maintainence cost for Autopilot is expensive so we go for Standard option in this documentation. Click [here](https://cloud.google.com/kubernetes-engine/docs/resources/autopilot-standard-feature-comparison) to know the difference between Autopilot and Standard.
4. Provide the suitable name for your cluster and select the region from the dropdown list.
<p align="center">
<img align="center" src="/docs/gke-1.png" alt="Logo" style="filter: drop-shadow(0px 0px 10px rgba(0, 0, 0, 0.5));" width="70%">
</p>
5. Choose the compute engine machine type from the Nodes section under default-pool. For CPM the minimum machine type requirement will be e2-standard-4(4vCPU,16 GB memory). Also make sure you enable the cluster autoscaling if you are planning to scale your pod vertically.
<p align="center">
<img align="center" src="/docs/gke-2.png" alt="Logo" style="filter: drop-shadow(0px 0px 10px rgba(0, 0, 0, 0.5));" width="70%">
</p>

<p align="center">
<img align="center" src="/docs/gke-3.png" alt="Logo" style="filter: drop-shadow(0px 0px 10px rgba(0, 0, 0, 0.5));" width="70%">
</p>

6. Click on `Create` button and wait for the Cluster to be ready.

### Step2: Connect to Cluster
1. After you cluster is created you can see the green check next to it. Once you see the check, click on the three dots next to your cluster to click on `Connect`.
2. Click on `Run in Cloud Shell` option and press enter.

### Step3: Deploy via Helm Chart
1. Add the helm repo by running below command.
```bash
helm repo add repo-helm-charts https://nfdi4chem.github.io/repo-helm-charts/
```
2. Run the below command to deploy the CPM app.
```bash
helm install myrelease repo-helm-charts/cheminfo-microservice
```
The release name (myrelease in this example) is used to identify the deployment, and it must be unique within the Kubernetes cluster.
The above command with deploy the service with the default configuration provided in [values.yml](https://github.com/NFDI4Chem/repo-helm-charts/blob/main/charts/cheminfo-microservice/values.yaml) file. To overwrite the default configuration please follow this [link](https://helm.sh/docs/chart_template_guide/values_files/) to learn more.

3. Helm will install the chart and deploy the application to your Kubernetes Cluster. To see the progress click on `Workloads` & `Services` tab. or run below commands in your Cloud Shell.
```bash
kubectl get pods
kubectl get services
```
4. Once all services are deployed you can see green check next to each services. If not then check the logs to learn more.
5. To access your service you may have to expose it either by setting the type to `Load Balancer` under service in values.yml file or by an Ingress depending upon your requirement.
To learn more about how to configure Nginx Ingress you can click on the link [here](https://github.com/GoogleCloudPlatform/community/blob/master/archived/nginx-ingress-gke/index.md#deploying-the-nginx-ingress-controller-with-helm).

### Step4: Clean up
To avoid incurring charges to your Google Cloud account for the resources used in this tutorial, either delete the project that contains the resources, or keep the project and delete resources by running below command.
```bash
helm delete myrelease
```

## Scaling
In case of performance issue, the CPM application can be scaled accordingly. The Helm chart for CPM comes packaged with Horizontal Pod Autoscaler. Horizontal Pod Autoscaler (HPA) is a Kubernetes feature that automatically adjusts the number of replica pods in a deployment or replica set based on observed CPU utilization or other select metrics. This allows your Kubernetes cluster to dynamically respond to changes in application load, ensuring optimal resource utilization and application availability.
You can set the `targetCPUUtilizationPercentage` and `targetMemoryUtilizationPercentage` values in values.yml file according to your need and demand, which is the deciding factor to trigger the scaling. To learn more about different types of scaling in Kubernetes and GKE follow the official [documentation](https://cloud.google.com/kubernetes-engine/docs/concepts/cluster-autoscaler) of Google Cloud.

If your application is deployed via Docker Compose then follow the documentation here for [scaling](/docker.html#docker-compose).


### Contribute or Report an issue
Thank you for your valuable assistance in enhancing our deployment process. If you would like to contribute, kindly create a pull request in our [GitHub](https://github.com/NFDI4Chem/repo-helm-charts) repository. For any issues or bugs you have encountered, please feel free to create an [issue](https://github.com/NFDI4Chem/repo-helm-charts/issues) in the same or write to us at caffeine-devs@uni-jena.de.
Your feedback is greatly appreciated.



References - https://cloud.google.com/docs
24 changes: 24 additions & 0 deletions docs/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,28 @@ docker pull caffeinejena/cheminformatics-python-microservice:[tag]
```bash
docker run -d -p 8080:80 --name [image-name] caffeinejena/cheminfo-microservice:[tag]

```

# Docker Compose
[Docker Compose](https://docs.docker.com/get-started/08_using_compose/) is a tool that helps you define and share multi-container applications. With Compose, you can create a YAML file to define the services and with a single command, you can spin everything up or tear it all down.
The Cheminformatics Python Microservice comes packaged with docker-compose file which you can use to deploy your application in your server. To deploy using Docker compose follow the steps as described below.

### Installation
1. Before you run the command make sure you've installed Docker including docker-compose support. If not then follow the link [here](https://docs.docker.com/compose/install/).
2. Clone the repository
```bash
git clone https://github.com/Steinbeck-Lab/cheminformatics-python-microservice.git
cd cheminformatics-python-microservice
```
3. For local deployment
```bash
docker-compose up -d
```
4. For production deployment
```bash
docker-compose -f ops/docker-compose-prod.yml up -d
```
5. Scaling in case of performance issues - This service file supports the docker-compose builtin scaling load balanced by [Traefik](https://doc.traefik.io/traefik/). For example to add 3 additional application containers you can simply invoke:
```bash
docker-compose -f ops/docker-compose-prod.yml up -d --scale web=3 --no-recreate
```
Binary file added docs/public/docs/gke-1.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 docs/public/docs/gke-2.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 docs/public/docs/gke-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d04d88c

Please sign in to comment.