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

fix(ksonnet): don't depend on specific k8s version #2525

Merged
merged 3 commits into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 3 additions & 9 deletions docs/sources/installation/tanka.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,11 @@ 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 init # not required if you already ran `tk 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 Expand Up @@ -89,4 +82,5 @@ loki + promtail + gateway {
Notice that `container_root_path` is your own data root for the Docker Daemon.
Run `docker info | grep "Root Dir"` to get the root path.

Run `tk show environments/loki` to see the manifests that will be deployed to the cluster. Run `tk apply environments/loki` to deploy the manifests.
Run `tk show environments/loki` to see the manifests that will be deployed to
the cluster. Run `tk apply environments/loki` to deploy the manifests.
7 changes: 5 additions & 2 deletions production/ksonnet/loki-canary/loki-canary.libsonnet
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
local config = import 'config.libsonnet';
local k = import 'ksonnet-util/kausal.libsonnet';

// backwards compatibility with ksonnet
local envVar = if std.objectHasAll(k.core.v1, 'envVar') then k.core.v1.envVar else k.core.v1.container.envType;

k + config {
namespace: $.core.v1.namespace.new($._config.namespace),

Expand All @@ -16,8 +19,8 @@ k + config {
container.withPorts($.core.v1.containerPort.new(name='http-metrics', port=80)) +
container.withArgsMixin($.util.mapToFlags($.loki_canary_args)) +
container.withEnv([
$.core.v1.envVar.fromFieldPath('HOSTNAME', 'spec.nodeName'),
$.core.v1.envVar.fromFieldPath('POD_NAME', 'metadata.name'),
envVar.fromFieldPath('HOSTNAME', 'spec.nodeName'),
envVar.fromFieldPath('POD_NAME', 'metadata.name'),
]),

local daemonSet = $.apps.v1.daemonSet,
Expand Down
9 changes: 0 additions & 9 deletions production/ksonnet/loki/jsonnetfile.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,6 @@
}
},
"version": "master"
},
{
"source": {
"git": {
"remote": "https://github.com/jsonnet-libs/k8s-alpha.git",
"subdir": "1.14"
}
},
"version": "master"
}
],
"legacyImports": true
Expand Down
10 changes: 0 additions & 10 deletions production/ksonnet/loki/jsonnetfile.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@
},
"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
Expand Down
5 changes: 4 additions & 1 deletion production/ksonnet/promtail/promtail.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ local scrape_config = import './scrape_config.libsonnet';
local config = import 'config.libsonnet';
local k = import 'ksonnet-util/kausal.libsonnet';

// backwards compatibility with ksonnet
local envVar = if std.objectHasAll(k.core.v1, 'envVar') then k.core.v1.envVar else k.core.v1.container.envType;

k + config + scrape_config {
namespace:
$.core.v1.namespace.new($._config.namespace),
Expand Down Expand Up @@ -49,7 +52,7 @@ k + config + scrape_config {
container.withPorts($.core.v1.containerPort.new(name='http-metrics', port=80)) +
container.withArgsMixin($.util.mapToFlags($.promtail_args)) +
container.withEnv([
$.core.v1.envVar.fromFieldPath('HOSTNAME', 'spec.nodeName'),
envVar.fromFieldPath('HOSTNAME', 'spec.nodeName'),
]) +
container.mixin.readinessProbe.httpGet.withPath('/ready') +
container.mixin.readinessProbe.httpGet.withPort(80) +
Expand Down