forked from th2-net/th2-infra
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dmitry Makhrovsky
committed
Dec 2, 2020
1 parent
07d0cc6
commit c7c7d0d
Showing
92 changed files
with
7,861 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,266 @@ | ||
# th2 installation | ||
|
||
## Prerequisites | ||
Before you begin, please check the following prerequisites: | ||
* Fully functioning Kubernetes cluster suitable for your bussiness needs, please refer to [technical requirements](https://github.com/th2-net/th2-documentation/wiki/Technical-Requirements) | ||
* Operator-box that meets [hardware](https://github.com/th2-net/th2-documentation/wiki/Technical-Requirements) and [software](https://github.com/th2-net/th2-documentation/wiki/Technical-Requirements#software-requirements) requirements | ||
* Installed [Apache Cassandra](https://cassandra.apache.org/) - [technical requirements](https://github.com/th2-net/th2-documentation/wiki/Technical-Requirements#apache-cassandra-cluster-hardware-requirements) | ||
|
||
All th2 components are deployed via Helm charts by [Helm](https://helm.sh/) and [Helm Operator](https://docs.fluxcd.io/projects/helm-operator/en/stable/). | ||
|
||
## Steps | ||
The following steps should be performed on the operator-box for th2-infra deployment: | ||
<!--ts--> | ||
* [Download th2 git repositories](#th2-git-repositories) | ||
* [Cluster configuration](#cluster-configuration) | ||
* [th2 deployment](#th2-deployment) | ||
* [Monitoring deployment](#monitoring-deployment) | ||
<!--te--> | ||
|
||
|
||
## th2 git repositories | ||
Installation of th2 infra requires two git repositories. The information regarding this repository and its usage can be found in this guide below: | ||
* https://github.com/th2-net/th2-infra - consists charts and its values for deployment infrastructure components. The repository is common for everyone, but you can fork or clone it if you need to customize values. | ||
* https://github.com/th2-net/th2-infra-schema-demo - schema repository. It's used by `th2-infra-mgr`. | ||
|
||
The first step that should be done in the th2 deployment process is copying th2-infra repository into your operator-box: | ||
``` | ||
git clone https://github.com/th2-net/th2-infra.git | ||
``` | ||
change the current directory | ||
``` | ||
cd ./th2-infra | ||
``` | ||
Then https://github.com/th2-net/th2-infra-schema-demo should be created in your git as a fork or template: | ||
* [how to create template](https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/creating-a-repository-from-a-template) | ||
* [how to fork](https://docs.github.com/en/free-pro-team@latest/github/getting-started-with-github/fork-a-repo#fork-an-example-repository) | ||
|
||
## Cluster configuration | ||
Once all of the required software is installed on your test-box and operator-box and th2-infra repositories are ready you can start configuring the cluster. The following picture describes th2-infra cluster configuration: | ||
|
||
image | ||
|
||
th2 infra components are split into two namespaces: _`monitoring`_ and _`service`_. These namespaces will be created below. | ||
|
||
Next components of prometheus and grafana monitoring stack are deployed into _`monitoring`_ namespace: | ||
* [kubernetes-dashboard](https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/) | ||
* [grafana](https://grafana.com/oss/grafana/) | ||
* [loki](https://grafana.com/oss/loki/) | ||
* [prometheus](https://grafana.com/oss/prometheus/) | ||
|
||
The _`service`_ namespace is used for core services of this project: | ||
* [RabbitMQ](https://www.rabbitmq.com/) | ||
* [NGINX Ingress Controller](https://kubernetes.github.io/ingress-nginx/) | ||
* [Helm Operator](https://github.com/fluxcd/helm-operator) | ||
|
||
and for infrastructure components: | ||
* [th2-infra-editor]() | ||
* [th2-infra-operator](https://github.com/th2-net/th2-infra-operator) | ||
* [th2-infra-mgr](https://github.com/th2-net/th2-infra-mgr) | ||
|
||
### Create namespaces | ||
Commands: | ||
``` | ||
kubectl create namespace monitoring | ||
kubectl create namespace service | ||
``` | ||
You can check result using this command: | ||
``` | ||
kubectl get namespaces | ||
``` | ||
In the output you should see the names of these namespaces: | ||
``` | ||
NAME STATUS AGE | ||
....... | ||
monitoring Active 15s | ||
service Active 7s | ||
....... | ||
``` | ||
|
||
### Set namespace `service` as a current | ||
It's an optional step, but it gets slightly simpler checking result of installation. In all installation commands we explicitly define namespaces to avoid possible mistakes. | ||
``` | ||
kubectl config set-context --current --namespace=service | ||
``` | ||
|
||
### Set up access to Git repositories | ||
Two types of access to repositories are used in th2 - via `https` and `ssh`. The `ssh` access is required by **th2-infra-mgr** component and `https` by **helm-operator**. So, we need to set up both of them. | ||
#### 1. SSH access: | ||
|
||
1. Generate keys without passphrase | ||
``` | ||
ssh-keygen -t rsa -m pem -f ~/.ssh/id_gh_rsa | ||
``` | ||
2. [Add a new SSH key to your GitHub account](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/adding-a-new-ssh-key-to-your-github-account) | ||
3. Create infra-mgr secret from private key: | ||
``` | ||
kubectl -n service create secret generic infra-mgr --from-file=infra-mgr=$HOME/.ssh/id_gh_rsa | ||
``` | ||
#### 2. HTTPS access for charts (part of th2-infra repository): | ||
Create secret for git access (only for private repositories) | ||
``` | ||
kubectl -n service create secret generic git-chart-creds --from-literal=username=git-username --from-literal=password=git-password | ||
``` | ||
If you use a private repository for charts of project (for some security reasons i.e.) instead of public, you should provide valid credentials for `git-username` and `git-password` in the command above. Using Personal Access Token(PAT) is the better choice instead of using clear password. | ||
Read more about this: | ||
* [Creating a personal access token on Github](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) | ||
* [Creating a deployment token on Gitlab](https://docs.gitlab.com/ee/user/project/deploy_tokens/#creating-a-deploy-token) | ||
If you use a public repository for the charts of project, you can keep the values for `git-username` and `git-password` as is or use empty values like this: | ||
``` | ||
kubectl -n service create secret generic git-chart-creds --from-literal=username= --from-literal=password= | ||
``` | ||
### Set the repository with configuration | ||
* set `infraMgr.git.repository` value in the [./values/service.values.yaml](./values/service.values.yaml) file to **ssh** link of your schema repository, e.g: | ||
``` | ||
infraMgr: | ||
git: | ||
repository: [email protected]:th2-net/th2-infra-demo-configuration.git | ||
``` | ||
### Define cassandra host name | ||
* set `cassandra.host` value for cassandra in the [./values/service.values.yaml](./values/service.values.yaml) file. | ||
``` | ||
cassandra: | ||
internal: false | ||
host: <cassandra-host> | ||
``` | ||
### Define th2 ingress hostname | ||
Please add `ingress.hostname` value if required into [./values/service.values.yaml](./values/service.values.yaml) file otherwise th2 http services will be available on node IP address | ||
``` | ||
ingress: | ||
host: example.com | ||
``` | ||
### Create directories on the particular node for PersistentVolumes: | ||
Note: we use HostPath type of [Persistent Volume(PV)](https://kubernetes.io/docs/concepts/storage/persistent-volumes/) to store data only for demo deployment, but this type isn't recommended for production deployment. Please read documentation to chose appropriated type for your environment.<br> | ||
Next command requires root permissions. | ||
``` | ||
mkdir /opt/prometheus /opt/grafana /opt/loki /opt/rabbitmq /opt/components | ||
``` | ||
If you would like to include read components into your configuration, you also need to set up dedicated PersistentVolume for th2-read log directory. Details can be found in th2-read-log [README.md](https://github.com/th2-net/th2-read-log#configuration) | ||
### Create secret with th2 credentials | ||
Create secrets.yaml in `./` folder (*do not commit into git*). Please provide valid credentials to access to cassandra DB. Example: | ||
``` | ||
# reguired only if images in private repository | ||
# productRegistry: | ||
# username: user | ||
# password: password | ||
# name: registry.example.com # core components registry | ||
|
||
# reguired only if images in private repository | ||
# solutionRegistry: | ||
# username: user | ||
# password: password | ||
# name: private-registry.example.com # components registry | ||
|
||
cassandra: | ||
dbUser: | ||
user: <user-name> | ||
password: <password> | ||
|
||
rabbitmq: | ||
rabbitmqUsername: th2 | ||
rabbitmqPassword: rab-pass | ||
managementUsername: th2-mng | ||
managementPassword: rab-mng-pass | ||
# must be random string | ||
rabbitmqErlangCookie: cookie | ||
``` | ||
## th2 deployment | ||
### Install helm-operator | ||
``` | ||
helm repo add fluxcd https://charts.fluxcd.io | ||
helm install --version=1.2.0 helm-operator -n service fluxcd/helm-operator -f ./values/helm-operator.values.yaml | ||
``` | ||
### Install NGINX Ingress Controller | ||
* Install NGINX Ingress Controller: | ||
``` | ||
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx | ||
helm install -n service --version=3.12.0 ingress ingress-nginx/ingress-nginx -f ./values/ingress.values.yaml | ||
``` | ||
* Check result: | ||
* command: | ||
``` | ||
kubectl get pods | ||
``` | ||
* output: | ||
``` | ||
NAME READY STATUS RESTARTS AGE | ||
........ | ||
ingress-ingress-nginx-controller-7979dcdd85-mw42w 1/1 Running 0 30s | ||
........ | ||
``` | ||
### Install infrastructure components and ingress-rules via Helm and HelmOperator release in service namespace | ||
``` | ||
kubectl apply -n service -f ./values/ingress-rules.helmrelease.yaml | ||
helm install th2-infra-base -n service ./th2-service/ -f ./values/service.values.yaml -f ./secrets.yaml | ||
``` | ||
Wait for all pods in service namespace are up and running, once completed proceed with [schema configuration](https://github.com/th2-net/th2-infra-schema-demo/blob/master/README.md) to deploy th2 namespaces. | ||
## Monitoring deployment | ||
* Switch namespace to monitoring | ||
``` | ||
kubectl config set-context --current --namespace=monitoring | ||
``` | ||
* Install [Kubernetes Dashboard](https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/) | ||
``` | ||
helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/ | ||
helm install dashboard -n monitoring kubernetes-dashboard/kubernetes-dashboard -f ./values/dashboard.values.yaml | ||
``` | ||
* Set node name in `./values/pvs.yaml` | ||
* Create PVs and PVCs: | ||
``` | ||
kubectl apply -f ./values/pvs.yaml | ||
kubectl apply -f ./values/pvcs.yaml | ||
``` | ||
* Deploy components | ||
``` | ||
helm repo add loki https://grafana.github.io/loki/charts | ||
helm repo add stable https://charts.helm.sh/stable | ||
helm upgrade --install loki --namespace=monitoring loki/loki-stack -f ./values/loki.values.yaml | ||
helm upgrade --install prometheus stable/prometheus-operator -n monitoring -f ./values/prometheus-operator.values.yaml | ||
``` | ||
* Check result: | ||
* command: | ||
``` | ||
kubectl get pods | ||
``` | ||
* output: | ||
``` | ||
NAME READY STATUS RESTARTS AGE | ||
........ | ||
pod/dashboard-kubernetes-dashboard-77d85586db-j9v8f 1/1 Running 0 56s | ||
alertmanager-prometheus-prometheus-oper-alertmanager-0 2/2 Running 0 75s | ||
loki-0 1/1 Running 0 4m47s | ||
loki-promtail-wqfml 1/1 Running 0 4m47s | ||
prometheus-grafana-68f8dd6d57-2gtns 2/2 Running 0 82s | ||
prometheus-kube-state-metrics-75d4cc9dbd-psb88 1/1 Running 0 82s | ||
prometheus-prometheus-node-exporter-gfzp6 1/1 Running 0 82s | ||
prometheus-prometheus-oper-operator-df668d457-snxks 1/1 Running 0 82s | ||
prometheus-prometheus-prometheus-oper-prometheus-0 3/3 Running 1 65s | ||
........ | ||
``` | ||
default password in Grafana: admin/prom-operator. Need to be changed | ||
Add loki Datasource as http://loki:3100 and import Dashboard from ./values/components-logs.json | ||
* Check access to Grafana _(default user/password: `admin/prom-operator`. Need to be changed)_: <br> | ||
http://your-host:30000/grafana/login | ||
# Links: | ||
- Kubernetes dashboard http://your-host:30000/dashboard/ | ||
- Grafana http://your-host:30000/grafana/ | ||
- th2-infra-editor http://your-host:30000/editor/ | ||
- th2-reports http://your-host:30000/your-namespace/ | ||
- RabbitMQ http://your-host:30000/rabbitmq/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*.orig | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
dependencies: | ||
- name: rabbitmq-ha | ||
repository: https://kubernetes-charts.storage.googleapis.com/ | ||
version: 1.44.4 | ||
- name: cassandra | ||
repository: https://charts.bitnami.com/bitnami | ||
version: 5.4.1 | ||
digest: sha256:0853d8f347d3a39a4c6d8b6153867a38ed19187ecb6f39a6a0ecab9939e1d271 | ||
generated: "2020-06-08T18:18:56.5513199+03:00" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
apiVersion: v2 | ||
name: custom-component | ||
description: Chart for custom-component service | ||
|
||
# A chart can be either an 'application' or a 'library' chart. | ||
# | ||
# Application charts are a collection of templates that can be packaged into versioned archives | ||
# to be deployed. | ||
# | ||
# Library charts provide useful utilities or functions for the chart developer. They're included as | ||
# a dependency of application charts to inject those utilities and functions into the rendering | ||
# pipeline. Library charts do not define any templates and therefore cannot be deployed. | ||
type: application | ||
|
||
# This is the chart version. This version number should be incremented each time you make changes | ||
# to the chart and its templates, including the app version. | ||
# Versions are expected to follow Semantic Versioning (https://semver.org/) | ||
version: 0.1.0 | ||
|
||
# This is the version number of the application being deployed. This version number should be | ||
# incremented each time you make changes to the application. Versions are not expected to | ||
# follow Semantic Versioning. They should reflect the version the application is using. | ||
appVersion: 1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
act | ||
=== | ||
Chart for act service | ||
|
||
Current chart version is `0.1.0` | ||
|
||
|
||
|
||
|
||
|
||
## Chart Values | ||
|
||
| Key | Type | Default | Description | | ||
|-----|------|---------|-------------| | ||
| acts[0].image | string | `"nexus.exactpro.com:9000/th2-act:1.0.15.62"` | | | ||
| acts[0].name | string | `"act"` | | |
Oops, something went wrong.