|
1 | 1 | # Deploy Loki to Kubernetes
|
2 | 2 |
|
3 |
| -## Prerequisites |
4 |
| - |
5 |
| -Make sure you have a recent version of [Tanka](https://github.com/grafana/tanka). Follow their [install instructions](https://tanka.dev/install) to do so. Make sure to install [jsonnet-bundler](https://github.com/jsonnet-bundler/jsonnet-bundler) as well. |
6 |
| - |
7 |
| -```bash |
8 |
| -# Verify it works |
9 |
| -$ tk --version |
10 |
| -tk version v0.6.1 |
11 |
| -``` |
12 |
| - |
13 |
| -In your config repo, if you don't yet have a Tanka project set up: |
14 |
| - |
15 |
| -```bash |
16 |
| -# create a directory (any name works) |
17 |
| -$ mkdir config && cd config/ |
18 |
| -$ tk init |
19 |
| -$ tk env add environments/loki --namespace=loki |
20 |
| -$ tk env set environments/loki --server=https://${K8S_MASTER_ADDRESS}:6443 |
21 |
| -``` |
22 |
| - |
23 |
| -## Deploying Promtail to your cluster. |
24 |
| - |
25 |
| -Grab the `promtail` module using jb: |
26 |
| - |
27 |
| -``` |
28 |
| -$ jb install github.com/grafana/loki/production/ksonnet/promtail |
29 |
| -``` |
30 |
| - |
31 |
| -Replace the contents of `environments/loki/main.jsonnet` with: |
32 |
| -```jsonnet |
33 |
| -local promtail = import 'promtail/promtail.libsonnet'; |
34 |
| -
|
35 |
| -promtail + { |
36 |
| - _config+:: { |
37 |
| - namespace: 'loki', |
38 |
| -
|
39 |
| - promtail_config+: { |
40 |
| - clients: [ |
41 |
| - { |
42 |
| - scheme:: 'https', |
43 |
| - hostname:: 'logs-us-west1.grafana.net', |
44 |
| - username:: 'user-id', |
45 |
| - password:: 'password', |
46 |
| - external_labels: {}, |
47 |
| - } |
48 |
| - ], |
49 |
| - container_root_path: '/var/lib/docker', |
50 |
| - }, |
51 |
| - }, |
52 |
| -} |
53 |
| -
|
54 |
| -``` |
55 |
| -Notice that `container_root_path` is your own data root for docker daemon, use `docker info | grep "Root Dir"` to get it. |
56 |
| - |
57 |
| -Now use `tk show environments/loki` to see the yaml, and `tk apply environments/loki` to apply it to the cluster. |
58 |
| - |
59 |
| -## Deploying Loki to your cluster. |
60 |
| - |
61 |
| -If you want to further also deploy the server to the cluster, then run the following to install the module: |
62 |
| - |
63 |
| -``` |
64 |
| -$ jb install github.com/grafana/loki/production/ksonnet/loki |
65 |
| -``` |
66 |
| -Be sure to replace the username, password and the relevant htpasswd contents. |
67 |
| -Replace the contents of `environments/loki/main.jsonnet` with: |
68 |
| - |
69 |
| -```jsonnet |
70 |
| -local gateway = import 'loki/gateway.libsonnet'; |
71 |
| -local loki = import 'loki/loki.libsonnet'; |
72 |
| -local promtail = import 'promtail/promtail.libsonnet'; |
73 |
| -
|
74 |
| -loki + promtail + gateway { |
75 |
| - _config+:: { |
76 |
| - namespace: 'loki', |
77 |
| - htpasswd_contents: 'loki:$apr1$H4yGiGNg$ssl5/NymaGFRUvxIV1Nyr.', |
78 |
| -
|
79 |
| -
|
80 |
| - promtail_config: { |
81 |
| - scheme: 'http', |
82 |
| - hostname: 'gateway.%(namespace)s.svc' % $._config, |
83 |
| - username: 'loki', |
84 |
| - password: 'password', |
85 |
| - container_root_path: '/var/lib/docker', |
86 |
| - }, |
87 |
| - replication_factor: 3, |
88 |
| - consul_replicas: 1, |
89 |
| - }, |
90 |
| -} |
91 |
| -``` |
92 |
| -Notice that `container_root_path` is your own data root for docker daemon, use `docker info | grep "Root Dir"` to get it. |
93 |
| - |
94 |
| -Use `tk show environments/loki` to see the manifests being deployed to the cluster. |
95 |
| -Finally `tk apply environments/loki` will deploy the server components to your cluster. |
| 3 | +See the [Tanka Installation Docs](../../docs/sources/installation/tanka.md) |
0 commit comments