Skip to content

Commit

Permalink
Ksonnet docs (#2503)
Browse files Browse the repository at this point in the history
* adds jsonnet-libs/k8s-alpha, redirects tanka install docs

* removes vendor dir from loki ksonnet

* docs for non-GA tanka requirement

* Update docs/sources/installation/tanka.md

Co-authored-by: Ed Welch <ed@oqqer.com>

Co-authored-by: Ed Welch <ed@oqqer.com>
  • Loading branch information
owen-d and slim-bean committed Aug 13, 2020
1 parent 3486889 commit 6e3e2fa
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 93 deletions.
6 changes: 6 additions & 0 deletions docs/sources/installation/tanka.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@ Download and install the Loki and Promtail module using `jb`:

```bash
go get -u github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb
jb init
jb install github.com/grafana/loki/production/ksonnet/loki
jb install github.com/grafana/loki/production/ksonnet/promtail
```

Note: As of 2020-08-13 we use some as of yet non GA features, please override the `lib/k.libsonnet` with the following. This step will likely not be necessary in future tanka releases.

```jsonnet
(import 'github.com/jsonnet-libs/k8s-alpha/1.14/main.libsonnet')
+ (import 'github.com/jsonnet-libs/k8s-alpha/1.14/extensions/kausal-shim.libsonnet')
Be sure to replace the username, password and the relevant `htpasswd` contents.
Making sure to set the value for username, password, and `htpasswd` properly,
replace the contents of `environments/loki/main.jsonnet` with:
Expand Down
94 changes: 1 addition & 93 deletions production/ksonnet/README.md
Original file line number Diff line number Diff line change
@@ -1,95 +1,3 @@
# Deploy Loki to Kubernetes

## Prerequisites

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.

```bash
# Verify it works
$ tk --version
tk version v0.6.1
```

In your config repo, if you don't yet have a Tanka project set up:

```bash
# create a directory (any name works)
$ mkdir config && cd config/
$ tk init
$ tk env add environments/loki --namespace=loki
$ tk env set environments/loki --server=https://${K8S_MASTER_ADDRESS}:6443
```

## Deploying Promtail to your cluster.

Grab the `promtail` module using jb:

```
$ jb install github.com/grafana/loki/production/ksonnet/promtail
```

Replace the contents of `environments/loki/main.jsonnet` with:
```jsonnet
local promtail = import 'promtail/promtail.libsonnet';
promtail + {
_config+:: {
namespace: 'loki',
promtail_config+: {
clients: [
{
scheme:: 'https',
hostname:: 'logs-us-west1.grafana.net',
username:: 'user-id',
password:: 'password',
external_labels: {},
}
],
container_root_path: '/var/lib/docker',
},
},
}
```
Notice that `container_root_path` is your own data root for docker daemon, use `docker info | grep "Root Dir"` to get it.

Now use `tk show environments/loki` to see the yaml, and `tk apply environments/loki` to apply it to the cluster.

## Deploying Loki to your cluster.

If you want to further also deploy the server to the cluster, then run the following to install the module:

```
$ jb install github.com/grafana/loki/production/ksonnet/loki
```
Be sure to replace the username, password and the relevant htpasswd contents.
Replace the contents of `environments/loki/main.jsonnet` with:

```jsonnet
local gateway = import 'loki/gateway.libsonnet';
local loki = import 'loki/loki.libsonnet';
local promtail = import 'promtail/promtail.libsonnet';
loki + promtail + gateway {
_config+:: {
namespace: 'loki',
htpasswd_contents: 'loki:$apr1$H4yGiGNg$ssl5/NymaGFRUvxIV1Nyr.',
promtail_config: {
scheme: 'http',
hostname: 'gateway.%(namespace)s.svc' % $._config,
username: 'loki',
password: 'password',
container_root_path: '/var/lib/docker',
},
replication_factor: 3,
consul_replicas: 1,
},
}
```
Notice that `container_root_path` is your own data root for docker daemon, use `docker info | grep "Root Dir"` to get it.

Use `tk show environments/loki` to see the manifests being deployed to the cluster.
Finally `tk apply environments/loki` will deploy the server components to your cluster.
See the [Tanka Installation Docs](../../docs/sources/installation/tanka.md)
9 changes: 9 additions & 0 deletions production/ksonnet/loki/jsonnetfile.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@
}
},
"version": "master"
},
{
"source": {
"git": {
"remote": "https://github.com/jsonnet-libs/k8s-alpha.git",
"subdir": "1.14"
}
},
"version": "master"
}
],
"legacyImports": true
Expand Down
56 changes: 56 additions & 0 deletions production/ksonnet/loki/jsonnetfile.lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"version": 1,
"dependencies": [
{
"source": {
"git": {
"remote": "https://github.com/grafana/jsonnet-libs.git",
"subdir": "consul"
}
},
"version": "8629e32d04a0eefdce41224540f0d31de7d40deb",
"sum": "whodWjF2UjlDT6rDiBsxbT+71UGD2J7IKiVxJETrXCA="
},
{
"source": {
"git": {
"remote": "https://github.com/grafana/jsonnet-libs.git",
"subdir": "jaeger-agent-mixin"
}
},
"version": "8629e32d04a0eefdce41224540f0d31de7d40deb",
"sum": "DsdBoqgx5kE3zc6fMYnfiGjW2+9Mx2OXFieWm1oFHgY="
},
{
"source": {
"git": {
"remote": "https://github.com/grafana/jsonnet-libs.git",
"subdir": "ksonnet-util"
}
},
"version": "8629e32d04a0eefdce41224540f0d31de7d40deb",
"sum": "TGgjbv8oGfmMNjfvcgxi2cX9RAJKGZnYGLEhzK2wNjM="
},
{
"source": {
"git": {
"remote": "https://github.com/grafana/jsonnet-libs.git",
"subdir": "memcached"
}
},
"version": "8629e32d04a0eefdce41224540f0d31de7d40deb",
"sum": "AIspZ151p0qkxVc9tuoAEYNrkazV6QncWWsIsarK9GE="
},
{
"source": {
"git": {
"remote": "https://github.com/jsonnet-libs/k8s-alpha.git",
"subdir": "1.14"
}
},
"version": "4423ca26d1762943b9975fd4f5cc229e814fe8b6",
"sum": "00qOXX9Ddf0r2AR3NX7d9A/9MFaAesdGxCs6sXUobok="
}
],
"legacyImports": false
}

0 comments on commit 6e3e2fa

Please sign in to comment.