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

Ksonnet docs #2503

Merged
merged 4 commits into from
Aug 13, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/sources/installation/tanka.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,18 @@ 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
```

Since we use some as of yet non GA features, please override the `lib/k.libsonnet` with the following. This step won't be necessary in a future tanka release.

```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')
```

owen-d marked this conversation as resolved.
Show resolved Hide resolved
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
}