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

Configurable grafana ports #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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)]) +
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be done via the configuration file as well no? I think I'd prefer to keep all configuration possible within the config file. GF_INSTALL_PLUGINS is only there because it's the only way to configure plugins to install.

container.withVolumeMounts(volumeMounts) +
container.withPorts(containerPort.newNamed(portName, targetPort)) +
container.mixin.readinessProbe.httpGet.withPath('/api/health') +
Expand Down