Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide helm chart deploy method #707

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
128 changes: 64 additions & 64 deletions kubernetes/README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
# Running GrimoireLab with Kubernetes

In this folder are configuration manifests for deploying GrimoireLab using [Kubernetes](https://kubernetes.io). You will need a functional Kubernetes cluster, and you should be able to deploy both versions on k8s, kind, or minikube. There are certainly other options out there as well.

# Requirements

* [Git](https://git-scm.com/) client
* Kubernetes 1.17+ (managed or local, including kind, minikube, or k3s)
* [kubectl client](https://kubernetes.io/docs/tasks/tools/install-kubectl/) and admin credentials to aforementioned Kubernetes cluster

# Getting Started

1. Clone this project:
```console
git clone https://github.com/chaoss/grimoirelab
```

2. Since it's impossible to reference external files from within yaml, the configuration templates provided in [`default-grimoirelab-settings`](../default-grimoirelab-settings) are copied to various config/secret maps.

* [`30-hatstall-config.yml`] - Contains [`apache-hatstall.conf`](../default-grimoirelab-settings/apache-hatstall.conf)
* [`31-hatstall-secret.yml`] - Contains [`shdb.cfg`](../default-grimoirelab-settings/shdb.cfg)
* [`50-mordred-config.yml`] - Contains [`projects.json`](../default-grimoirelab-settings/projects.json) and [`identities.yml`](../default-grimoirelab-settings/identities.yml)
* [`51-mordred-config-aliases.yml`] - Contains [`aliases.json`](../default-grimoirelab-settings/aliases.json)
* [`52-mordred-config-identities.yml`] - Contains [`identities.yml`](../default-grimoirelab-settings/identities.yml)
* [`53-mordred-secret.yml`] - Contains [`setup.cfg`](../default-grimoirelab-settings/setup.cfg)

The two files you'll likely want to modify at first are `50-mordred-config.yml`, which includes the relevant project locations in `projects.json` in addition to `53-mordred-secret.yml`, which contains all the configuration settings for collecting the data for your projects. This includes api keys, passwords, and other important artifacts.

See [below](#more-information) more information about these files format.

3. Launch the project and use `port-forward` as shown in this example to access the dashboard.

```console
cd grimoirelab/kubernetes/secure
kubectl apply -f .
kubectl port-forward service/kibiter 5601 -n grimoire
```

Launch your browser and navigate to `http://localhost:5601`, and login with the user name `admin` and password `admin`.

To manage the contributors identities, you may port-forward the [Hatstall](https://github.com/chaoss/grimoirelab-hatstall) application as well.

```console
kubectl port-forward service/hatstall 8000:80 -n grimoire
```

Once forwarded, access your browser at `http://localhost:8000`, and login using the user name `admin`, and password `admin`

---

## Using an insecure environment

Follow the same steps as above, but use the manifests in the `insecure` folder.


# More information

* [The `projects.json` file format](https://github.com/chaoss/grimoirelab-sirmordred#projectsjson)
* [The `setup.cfg` file format](https://github.com/chaoss/grimoirelab-sirmordred#setupcfg)
* Getting API tokens for different services:
* [GitHub](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line)
* [GitLab](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html)
* [Meetup](https://secure.meetup.com/es-ES/meetup_api/oauth_consumers/)
* [Slack](https://get.slack.help/hc/en-us/articles/215770388-Create-and-regenerate-API-tokens)
# Running GrimoireLab with Kubernetes
In this folder are configuration manifests for deploying GrimoireLab using [Kubernetes](https://kubernetes.io). You will need a functional Kubernetes cluster, and you should be able to deploy both versions on k8s, kind, or minikube. There are certainly other options out there as well.
# Requirements
* [Git](https://git-scm.com/) client
* Kubernetes 1.17+ (managed or local, including kind, minikube, or k3s)
* [kubectl client](https://kubernetes.io/docs/tasks/tools/install-kubectl/) and admin credentials to aforementioned Kubernetes cluster
# Getting Started
1. Clone this project:
```console
git clone https://github.com/chaoss/grimoirelab
```
2. Since it's impossible to reference external files from within yaml, the configuration templates provided in [`default-grimoirelab-settings`](../default-grimoirelab-settings) are copied to various config/secret maps.
* [`30-hatstall-config.yml`] - Contains [`apache-hatstall.conf`](../default-grimoirelab-settings/apache-hatstall.conf)
* [`31-hatstall-secret.yml`] - Contains [`shdb.cfg`](../default-grimoirelab-settings/shdb.cfg)
* [`50-mordred-config.yml`] - Contains [`projects.json`](../default-grimoirelab-settings/projects.json) and [`identities.yml`](../default-grimoirelab-settings/identities.yml)
* [`51-mordred-config-aliases.yml`] - Contains [`aliases.json`](../default-grimoirelab-settings/aliases.json)
* [`52-mordred-config-identities.yml`] - Contains [`identities.yml`](../default-grimoirelab-settings/identities.yml)
* [`53-mordred-secret.yml`] - Contains [`setup.cfg`](../default-grimoirelab-settings/setup.cfg)
The two files you'll likely want to modify at first are `50-mordred-config.yml`, which includes the relevant project locations in `projects.json` in addition to `53-mordred-secret.yml`, which contains all the configuration settings for collecting the data for your projects. This includes api keys, passwords, and other important artifacts.
See [below](#more-information) more information about these files format.
3. Launch the project and use `port-forward` as shown in this example to access the dashboard.
```console
cd grimoirelab/kubernetes/secure
kubectl apply -f .
kubectl port-forward service/kibiter 5601 -n grimoire
```
Launch your browser and navigate to `http://localhost:5601`, and login with the user name `admin` and password `admin`.
To manage the contributors identities, you may port-forward the [Hatstall](https://github.com/chaoss/grimoirelab-hatstall) application as well.
```console
kubectl port-forward service/hatstall 8000:80 -n grimoire
```
Once forwarded, access your browser at `http://localhost:8000`, and login using the user name `admin`, and password `admin`
---
## Using an insecure environment
Follow the same steps as above, but use the manifests in the `insecure` folder.
# More information
* [The `projects.json` file format](https://github.com/chaoss/grimoirelab-sirmordred#projectsjson)
* [The `setup.cfg` file format](https://github.com/chaoss/grimoirelab-sirmordred#setupcfg)
* Getting API tokens for different services:
* [GitHub](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line)
* [GitLab](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html)
* [Meetup](https://secure.meetup.com/es-ES/meetup_api/oauth_consumers/)
* [Slack](https://get.slack.help/hc/en-us/articles/215770388-Create-and-regenerate-API-tokens)
43 changes: 43 additions & 0 deletions kubernetes/helm-chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: v2
name: grimoirelab
type: application
description: Nested Chart collection for all grimorelab services.
home: https://github.com/chaoss/grimoirelab
icon: https://www.gravatar.com/avatar/4154acefea56ed23bddaaa47a4850400
maintainers:
- name: Arie
url: https://github.com/Eroyi
version: 1.7.0 #Based on the "Github Release" version (which is the docker image tag referring from), not the actual application version.
appVersion: 1.0
dependencies:
- name: mordred
repository: file://charts/mordred
version: 1.7.0
- name: nginx
repository: file://charts/nginx
versio: 1.27.2
- name: sortinghat
repository: file://charts/sortinghat
version: 1.7.0
- name: sortinghat-worker
repository: file://charts/sortinghat-worker
version: 1.7.0
alias: sortinghatWorker
# External Dependencies
- name: opensearch-dashboard
version: 2.11.1
repository: file://charts/opensearch-dashboard
alias: opensearchDashboard
condition: opensearchDashboard.install
- name: opensearch-node
repository: file://charts/opensearch-node
version: 2.11.1
alias: opensearchNode
condition: opensearchNode.install
# - name: mariadb
# version: 19.1.0
# condition: mariadb.install
# - name: redis
# version: 20.2.1
# condition: redis.install

13 changes: 13 additions & 0 deletions kubernetes/helm-chart/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Thank you for installing {{ .Chart.Name }}.

To visualise data, you need to import dashboards into opensearch-dashboard.

1. Visit https://github.com/chaoss/grimoirelab-sigils/tree/master/panels/json/opensearch_dashboards
2. Download the dashboard you are interested
3. Open opensearch-dashboard console in your browser, login.
4. [If its the first install] Click "Explore on my own".
5. Click "Menu" on the top left corner, then go to "Management" - "Dashboard Management"
6. [If its the first install] Click "Index patterns" on the left to create the index patterns.
7. Click "Saved objects" on the left to import "ndjson" dashboard file you downloaded.
8. Drag or browser the dashboard file, select, then click "Import" - "Done" to import the dashboard.

199 changes: 199 additions & 0 deletions kubernetes/helm-chart/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
# Introduction
This chart launches a grimoirelab deployment on a Kubernetes cluster using the helm package manager.


# Prerequisites Component
- Mariadb
- Redis
- Opensearch **(!)**
- Opensearch Dashboard **(!)**


**(!)**: A component with this mark means this chart is already integrated with that component.

You can deploy and configure the **(!)** component within this chart via `Values.yaml`.

If you like to bring your own components, you can disable the installation of the built-in chart, with `install: false` option *(see detail below)*.



# Installing the Chart

To install the chart with the release name `grimoirelab`:
```console
helm install grimoirelab /path/to/chart --values /path/to/chart/values.yaml -n grimoirelab
```
`-n`: The namespace you would like to put this release in.

After installation, visit grimoirelab (opensearch-dashboard) homepage with:
`http://`opensearch_dashboard_ip`:5601`

To visualise data, you need to import dashboards into opensearch-dashboard.

1. Visit https://github.com/chaoss/grimoirelab-sigils/tree/master/panels/json/opensearch_dashboards
2. Download the dashboard you are interested
3. Open opensearch-dashboard console in your browser, login.
4. [If its the first install] Click "Explore on my own".
5. Click "Menu" on the top left corner, then go to "Management" - "Dashboard Management"
6. [If its the first install] Click "Index patterns" on the left to create the index patterns.
7. Click "Saved objects" on the left to import "ndjson" dashboard file you downloaded.
8. Drag or browser the dashboard file, select, then click "Import" - "Done" to import the dashboard.


# Configure the chart

Tips: Use `Ctrl+F / Command+F` search the keywords in `Values.yaml` for quick navigation.




## Global

Global values are meant to override the specific values across all sub-charts.
| Name | Description | Type | Default value |
| ---- | ----------- | ---- | ------------- |
| `topologyConfig` | The topology configuration for this chart, affect all components | map | {} |
| `imagePullSecrets` | Only required when you are pulling image from private registry | list | [] |
| `appName` | Name of this chart | string | "" |
| `credentials.database.username` | Plaintext. Username for database connection | string | "root" |
| `credentials.database.password` | Plaintext. Password for the database connection | string | "mar1adb4Gr1m0ir3Lab" |
| `credentials.opensearchNode.password` | Plaintext. Password for the opensearch connection | string | "admin" |
| `credentials.redis.password` | Plaintext. Password for the redis connection | string | "grimoirelab" |


## Component

### Grimoirelab components

> 1. Components' names will be omitted.
> 2. Resource value has been set to a minimum running quota.
> 3. You can disable these components: `opensearch-node`, `opensearch-dashboard`, `mariadb`, `redis`.

| Name | Description | Type | Default value |
| ---- | ----------- | ---- | ------------- |
| `install` | Installation toggle for this component. | boolean | true / false |
| `appConfig.replicas` | Replica count for this deployment | int | 1 |
| `appConfig.image` | Image for this deployment | string | --- |
| `appConfig.labels` | Labels for this deployment | map | {} |
| `appConfig.annotations` | Annotations for this deployment | map | {} |
| `appConfig.resources` | Resources quota for this deployment | map | --- |




## Dependencies

### Storage

| Name | Description | Type | Default value |
| ---- | ----------- | ---- | ------------- |
| `enabled` | Enable or disable persistent storage. | boolean | true / false |
| `volumes.name` | Name of this volumes when referencing in yaml | string | --- |
| `volumes.mountPath` | Path of this volumes to be mount into container | string | --- |
| `volumes.type` | Type of this volumes. `pvc`, `configmap` or `emptyDir` | string | --- |
| `volumes.storageClass` | The storage class that will be used when creating PVC | string | gp3 |
| `volumes.size` | Size of this volume | string | --- |
| `volumes.subPath` | Declare the `subPath` while mounting in `configmap` type | string | --- |


`volumes` have 3 types of schemas, here are the example:

#### 1. Persistent Volume
```yaml
- name: "volume-name"
mountPath: "/path/to/mount/in/container"
type: pvc
storageClass: your-storageClass
size: 1Gi
```
This will result:
- A Persistence Volume Claim
- With 1 Gigabyte storage
- with the storageClass you assigned
- Mounted as Volumes with the name "volume-name"
- in /path/to/mount/in/container



```yaml
- name: "volume-name"
mountPath: "/path/to/mount/in/container"
type: pvc
```
This will result:
- Mounted as Volumes with the name "volume-name". If these volumes are not created, the mounting attempt will fail.
- in /path/to/mount/in/container
> If you did NOT declare the size, PVC will not be created. If these volumes have not been created, the mounting attempt will fail.



### 2. Configmap as file
```yaml
- name: "config-name"
mountPath: "/path/to/file/in/container/file-name.txt"
type: configmap
subPath: "configmap-key-name"
```

This will result:
- Mounting file from Configmap with name "config-name".
- in /path/to/mount/in/container
> If the configmap has NOT been created, or the key declared in "subPath" is not found in the configmap, the mounting attempt will fail.



### 3. Empty directory
```yaml
- name: "volume-name"
mountPath: "path/to/mount/in/container"
type: emptyDir
```

This will result:
- Mounted as an empty directory with the name "volume-name"
- in /path/to/mount/in/container
> Data in this volume type will be lost when the pod is restarted.




## Service

| Name | Description | Type | Default value |
| ---- | ----------- | ---- | ------------- |
| `targetPort` | The port to expose for this deployment | int | --- |
| `schema` | The method when proxy the `targetPort`. `passthrough` will remain the original port, `http` will use 80 and `https` as 443 | string | passthrough |
| `type` | The type of the services for this deployment, default (empty) is `ClusterIP` | string | "" |

**Attention:** If you would like to change the service port in here, please make sure you have changed them in `templates/_ports.tpl` as well.



## Extra environments

You can put an extra environments list in here to inject into the container.
```yaml
- name: key
value: "value"
- name: foo
value: "bar"
```


# If you would like to bring your own databases and more...
Here are the strings you need to replace.

## Database
| Name | Description | Type | Default value |
| ---- | ----------- | ---- | ------------- |
| `SORTINGHAT_DB_HOST` | Database connection address, IP address or URL, without HTTP header | string | "mariadb" |
| `SORTINGHAT_DB_PORT` | Database connection port | string | "3306" |
| `SORTINGHAT_REDIS_HOST` | Redis connection address, IP address or URL, without HTTP header | string | "redis-master" |

## Opensearch and Dashboard
| Location | Key | Description | Type | Default value |
| -------- | --- | ----------- | ---- | ------------- |
| `templates/_envs.tpl` | `KIBANA_HOST` | Opensearch dashboard url | string | http://opensearch-dashboard: |
| `templates/_envs.tpl` | `OPENSEARCH_HOSTS` | Opensearch node url | string | https://opensearch-node: |
| `charts/mordred/templates/_mordred_config.tpl` | `es_collection.url` | Opensearch node url | string | @opensearch-node |
| `charts/mordred/templates/_mordred_config.tpl` | `es_enrichment.url` | Opensearch node url | string | @opensearch-node |
11 changes: 11 additions & 0 deletions kubernetes/helm-chart/charts/mordred/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v2
name: mordred
description: Mordred service for GrimoireLab.
home: https://github.com/chaoss/grimoirelab
icon: https://www.gravatar.com/avatar/4154acefea56ed23bddaaa47a4850400
maintainers:
- name: Arie
url: https://github.com/Eroyi
appVersion: 1.7.0 #Based on the "Github Release" version (which is the docker image tag referring from), not the actual application version.
version: 1.0

Loading