|
1 | | -# Distributed deployment |
| 1 | +# Running RIG on Kubernetes |
2 | 2 |
|
3 | | -Reactive Interaction Gateway (RIG) uses [Peerage library](https://github.com/mrluc/peerage) to do discovery in distributed mode (production Distillery release). |
| 3 | +## Kubectl |
4 | 4 |
|
5 | | -**Note:** If you don't care about distributed mode and don't want to do discovery, follow just `General configuration` section and ignore rest of the text. |
| 5 | +```bash |
| 6 | +kubectl apply -f kubectl/rig.yaml |
| 7 | +``` |
6 | 8 |
|
7 | | -## Configuration |
| 9 | +## Helm |
| 10 | + |
| 11 | +The Helm Charts are stored in [./helm2](./helm2) and [./helm3](./helm3) directory, which are essentially the same but only use a different `apiVersion` in the `Chart.yaml`. |
| 12 | + |
| 13 | +### Version 2 |
| 14 | + |
| 15 | +```bash |
| 16 | +cd helm2 |
| 17 | +# dry run to verify that everything is ok |
| 18 | +helm install --name=rig reactive-interaction-gateway --dry-run |
| 19 | +# install |
| 20 | +helm install --name=rig reactive-interaction-gateway |
| 21 | +``` |
| 22 | + |
| 23 | +### Version 3 |
| 24 | + |
| 25 | +```bash |
| 26 | +cd helm3 |
| 27 | +# dry run to verify that everything is ok |
| 28 | +helm install rig reactive-interaction-gateway --dry-run |
| 29 | +# install |
| 30 | +helm install rig reactive-interaction-gateway |
| 31 | +``` |
| 32 | + |
| 33 | +## Communication |
| 34 | + |
| 35 | +Both `kubectl` and `helm` deploy bunch of Kubernetes resources: |
| 36 | + |
| 37 | +- deployment - manages pod(s) |
| 38 | +- service - provides the main communication point for other applications |
| 39 | +- headless service - takes care of DNS discovery used internally |
8 | 40 |
|
9 | | -### General configuration |
| 41 | +To allow external communication (outside of your cluster) do: |
10 | 42 |
|
11 | | -1. Node host - Every node in cluster needs to be discoverable by other nodes. For that Elixir/Erlang uses so called `long name` or `short name`. We are using `long name` which is formed in the following way `app_name@node_host`. `app_name` is in our case set to `rig`, but `node_host` is taken from environment variable `NODE_HOST`. This can be either IP or container alias or whatever that is routable in network by other nodes. |
| 43 | +```bash |
| 44 | +# both helm versions |
| 45 | +helm upgrade --set service.type=LoadBalancer rig reactive-interaction-gateway |
| 46 | +# for kubectl update kubectl/rig.yaml to use a service of type LoadBalancer instead of ClusterIP |
| 47 | +``` |
12 | 48 |
|
13 | | -1. Node cookie - Nodes in Erlang cluster use cookies as a form of authorization/authentication between them. Only nodes with the same cookie can communicate together. It should be ideally some generated hash, set it to `NODE_COOKIE` environment variable. |
| 49 | +## Scaling |
14 | 50 |
|
15 | | -### DNS discovery |
| 51 | +Scale the deployment and create multiple pods |
16 | 52 |
|
17 | | -RIG currently supports distributed deployment via DNS discovery. To make it work, you need to set two environment variables: |
| 53 | +```bash |
| 54 | +helm upgrade --set service.type=LoadBalancer --set replicaCount=<replicas> rig reactive-interaction-gateway |
| 55 | +# or |
| 56 | +kubectl scale deployment/<deployment_name> --replicas <replicas> |
| 57 | +``` |
18 | 58 |
|
19 | | -1. Discovery type - Currently RIG supports only DNS discovery. To use DNS, set `DISCOVERY_TYPE` to `dns`. |
| 59 | +You can also inspect the logs of the pods with `kubectl logs <pod_name>` to see how they automatically re-balance Kafka consumers (if you are using Kafka) and adapt Proxy APIs from other nodes. |
20 | 60 |
|
21 | | -1. DNS name (address) - Address where peerage will do discovery for Node host addresses. Value is taken from environment variable `DNS_NAME`. |
| 61 | +## Configuration |
| 62 | + |
| 63 | +### Node host |
| 64 | + |
| 65 | +Every node in cluster needs to be discoverable by other nodes. For that Elixir/Erlang uses so called `long name` or `short name`. We are using `long name` which is formed in the following way `app_name@node_host`. `app_name` is in our case set to `rig` and `node_host` is taken from environment variable `NODE_HOST`. This can be either IP or container alias or whatever that is routable in network by other nodes. |
| 66 | + |
| 67 | +We are using the pod IP with: |
| 68 | + |
| 69 | +```yaml |
| 70 | +- name: NODE_HOST |
| 71 | + valueFrom: |
| 72 | + fieldRef: |
| 73 | + fieldPath: status.podIP |
| 74 | +``` |
22 | 75 |
|
23 | | -DNS discovery is executed every 5 seconds. |
| 76 | +### Node cookie |
| 77 | +
|
| 78 | +Nodes in Erlang cluster use cookies as a form of authorization/authentication between them. Only nodes with the same cookie can communicate together. Ideally, it is some generated hash, that's why we recommend adapting `NODE_COOKIE` environment variable in the `values.yaml`. |
24 | 79 |
|
25 | 80 | ### Additional configuration |
26 | 81 |
|
27 | | -When running in distributed mode, additional variables may be passed to the deployment in order to run the proper configuration. |
28 | | -Changes to these variables are required in most production circumstances. |
| 82 | +You can configure bunch of environment variables, please check the [Operator's Guide](https://accenture.github.io/reactive-interaction-gateway/docs/rig-ops-guide.html). |
| 83 | + |
| 84 | +## Cleanup |
| 85 | + |
| 86 | +```bash |
| 87 | +# kubectl |
| 88 | +kubectl delete -f kubectl/rig.yaml |
| 89 | +
|
| 90 | +# Helm v3 |
| 91 | +helm uninstall rig |
29 | 92 |
|
30 | | -For more information on configuration variables, please view the [Operator's Guide to the RIG](https://accenture.github.io/reactive-interaction-gateway/docs/rig-ops-guide.html) |
| 93 | +# Helm v2 |
| 94 | +helm delete --purge rig |
| 95 | +``` |
0 commit comments