Skip to content

Commit

Permalink
Configurable grafana ports
Browse files Browse the repository at this point in the history
  • Loading branch information
redbaron committed May 23, 2019
1 parent b6db6bd commit 4eb1ba5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions grafana/grafana.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet';

grafana+:: {
dashboards: {},
containerPort: { port: 3000, name: 'http' },
servicePort: { port: 3000, name: 'http' },
datasources: [{
name: 'prometheus',
type: 'prometheus',
Expand Down Expand Up @@ -66,7 +68,7 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet';
local service = k.core.v1.service;
local servicePort = k.core.v1.service.mixin.spec.portsType;

local grafanaServiceNodePort = servicePort.newNamed('http', 3000, 'http');
local grafanaServiceNodePort = servicePort.newNamed($._config.grafana.servicePort.name, $._config.grafana.servicePort.port, $._config.grafana.containerPort.name);

service.new('grafana', $.grafana.deployment.spec.selector.matchLabels, grafanaServiceNodePort) +
service.mixin.metadata.withLabels({ app: 'grafana' }) +
Expand All @@ -84,8 +86,8 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet';
local podSelector = deployment.mixin.spec.template.spec.selectorType;
local env = container.envType;

local targetPort = 3000;
local portName = 'http';
local targetPort = $._config.grafana.containerPort.port;
local portName = $._config.grafana.containerPort.name;
local podLabels = { app: 'grafana' };

local configVolumeName = 'grafana-config';
Expand Down Expand Up @@ -137,6 +139,7 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet';
local c =
container.new('grafana', $._config.imageRepos.grafana + ':' + $._config.versions.grafana) +
(if std.length($._config.grafana.plugins) == 0 then {} else container.withEnv([env.new('GF_INSTALL_PLUGINS', std.join(',', $._config.grafana.plugins))])) +
container.withEnvMixin([env.new('GF_SERVER_HTTP_PORT', '' + $._config.grafana.containerPort.port)]) +
container.withVolumeMounts(volumeMounts) +
container.withPorts(containerPort.newNamed(portName, targetPort)) +
container.mixin.readinessProbe.httpGet.withPath('/api/health') +
Expand Down

0 comments on commit 4eb1ba5

Please sign in to comment.