Skip to content

Commit

Permalink
build: Add custom grafana build image with plugins installed
Browse files Browse the repository at this point in the history
Updating the prometheus-operator charts to 8.1.2 results in dashboards
with no stats mainly because of missing plugins(grafana-piechart-panel).

In order to have all dashboards with stats, we build our custom grafana
image with the missing plugin installed.

This PR, will be reverted once a new version of the chart is released
since the fix will be included.

Fixes: #2175
  • Loading branch information
Ebaneck committed Jan 7, 2020
1 parent 2399e63 commit 08825e9
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 10 deletions.
7 changes: 4 additions & 3 deletions buildchain/buildchain/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,6 @@ def _operator_image(name: str, **kwargs: Any) -> targets.OperatorImage:
'kube-scheduler',
'nginx-ingress-defaultbackend-amd64',
],
constants.GRAFANA_REPOSITORY: [
'grafana',
],
constants.INGRESS_REPOSITORY: [
'nginx-ingress-controller',
],
Expand Down Expand Up @@ -217,6 +214,10 @@ def _operator_image(name: str, **kwargs: Any) -> targets.OperatorImage:
# }}}
# Container images to build {{{
TO_BUILD : Tuple[targets.LocalImage, ...] = (
_local_image(
name='grafana',
build_args={'GRAFANA_IMAGE_VERSION': versions.GRAFANA_IMAGE_VERSION},
),
_local_image(
name='salt-master',
build_args={'SALT_VERSION': versions.SALT_VERSION},
Expand Down
15 changes: 8 additions & 7 deletions buildchain/buildchain/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ def load_version_information() -> None:
CENTOS_BASE_IMAGE_SHA256 : str = \
'6ae4cddb2b37f889afd576a17a5286b311dcbf10a904409670827f6f9b50065e'

NGINX_IMAGE_VERSION : str = '1.15.8'
NODEJS_IMAGE_VERSION : str = '10.16.0'
GRAFANA_IMAGE_VERSION : str = '6.4.2'
NGINX_IMAGE_VERSION : str = '1.15.8'
NODEJS_IMAGE_VERSION : str = '10.16.0'

# Current build IDs, to be augmented whenever we rebuild the corresponding
# image, e.g. because the `Dockerfile` is changed, or one of the dependencies
Expand Down Expand Up @@ -106,11 +107,6 @@ def _version_prefix(version: str, prefix: str = 'v') -> str:
version='3.3.10',
digest='sha256:17da501f5d2a675be46040422a27b7cc21b8a43895ac998b171db1c346f361f7',
),
Image(
name='grafana',
version='6.4.2',
digest='sha256:8c2238eea9d3d39aeb6174db2e30b233fd2546128ec1fa1bc64f8058afd51e68',
),
Image(
name='k8s-sidecar',
version='0.1.20',
Expand Down Expand Up @@ -187,6 +183,11 @@ def _version_prefix(version: str, prefix: str = 'v') -> str:
digest='sha256:ed3ec0597c2d5b7102a7f62c661a23d8e4b34d910693fc23fd40bfb1d9404dcf',
),
# Local images
Image(
name='grafana',
version=GRAFANA_IMAGE_VERSION,
digest=None,
),
Image(
name='metalk8s-ui',
version=VERSION,
Expand Down
12 changes: 12 additions & 0 deletions images/grafana/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ARG GRAFANA_IMAGE_VERSION=6.4.2

FROM grafana/grafana:${GRAFANA_IMAGE_VERSION}

# cannot install plugin to /var/lib/grafana since it will be overwritten
# For more about this see https://community.grafana.com/t/install-plugin-from-dockerfile/2603/5
RUN mkdir -p /home/grafana/plugin && chown -R grafana:grafana /home/grafana/plugin

# set new plugin path
ENV GF_PATHS_PLUGINS=/home/grafana/plugin

RUN grafana-cli --pluginsDir /home/grafana/plugin plugins install grafana-piechart-panel
23 changes: 23 additions & 0 deletions images/grafana/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Build grafana image
===================

WHY?
====

After updating prometheus-operator charts to version 8.1.2, the
grafana-piechart-panel is not packaged with the upstream Grafana image and
hence Kubernetes Networking dashboards cannot display stats.

The best alternative was to contribute upstream, but it seems future releases
of the charts will come with Grafana 6.5.0 with the plugin issue already
solved.

In our best interest to release Metalk8s-2.4.2 with working dashboards,
we resolve to building our own custom Grafana 6.4.2 with the plugin already
installed.

Note:
=====

This custom build will be reverted once the Prometheus-operator charts is
updated some time in future.

0 comments on commit 08825e9

Please sign in to comment.