]> git.proxmox.com Git - ceph.git/blob - ceph/monitoring/grafana/build/Makefile
import quincy 17.2.0
[ceph.git] / ceph / monitoring / grafana / build / Makefile
1
2 GRAFANA_VERSION ?= 8.3.5-1
3 PIECHART_VERSION ?= "1.6.2"
4 STATUS_PANEL_VERSION ?= "1.0.11"
5 DASHBOARD_DIR := "../../ceph-mixin/dashboards_out"
6 DASHBOARD_PROVISIONING := "ceph-dashboard.yml"
7 IMAGE := "docker.io/redhat/ubi8:8.5"
8 PKGMGR := "dnf"
9 GF_CONFIG := "/etc/grafana/grafana.ini"
10 # clip off "-<whatever> from the end of GRAFANA_VERSION
11 CONTAINER_VERSION := $(shell /bin/echo $(GRAFANA_VERSION) | /bin/sed 's/-.*//')
12
13 ARCH ?= x86_64
14 ifeq "$(ARCH)" "arm64"
15 override ARCH := aarch64
16 endif
17
18 LOCALTAG=ceph-grafana:$(CONTAINER_VERSION)-$(ARCH)
19 TAG=ceph/ceph-grafana:$(CONTAINER_VERSION)-$(ARCH)
20
21 # Build a grafana instance - preconfigured for use within Ceph's dashboard UI
22
23 build :
24 echo "Creating base container"
25 $(eval CONTAINER := $(shell sudo buildah from ${IMAGE}))
26 # Using upstream grafana build
27 curl -fLO https://dl.grafana.com/oss/release/grafana-${GRAFANA_VERSION}.${ARCH}.rpm
28 sudo buildah copy $(CONTAINER) grafana-${GRAFANA_VERSION}.${ARCH}.rpm /tmp/grafana-${GRAFANA_VERSION}.${ARCH}.rpm
29 sudo buildah run $(CONTAINER) ${PKGMGR} install -y --setopt install_weak_deps=false --setopt=tsflags=nodocs /tmp/grafana-${GRAFANA_VERSION}.${ARCH}.rpm
30 sudo buildah run $(CONTAINER) ${PKGMGR} clean all
31 sudo buildah run $(CONTAINER) rm -f /tmp/grafana*.rpm
32 sudo buildah run $(CONTAINER) grafana-cli plugins install grafana-piechart-panel ${PIECHART_VERSION}
33 sudo buildah run $(CONTAINER) grafana-cli plugins install vonage-status-panel ${STATUS_PANEL_VERSION}
34 sudo buildah run $(CONTAINER) mkdir -p /etc/grafana/dashboards/ceph-dashboard
35 sudo buildah copy $(CONTAINER) ${DASHBOARD_DIR}/*.json /etc/grafana/dashboards/ceph-dashboard
36
37 @/bin/echo -e "\
38 apiVersion: 1 \\n\
39 providers: \\n\
40 - name: 'Ceph Dashboard' \\n\
41 torgId: 1 \\n\
42 folder: 'ceph-dashboard' \\n\
43 type: file \\n\
44 disableDeletion: false \\n\
45 updateIntervalSeconds: 3 \\n\
46 editable: false \\n\
47 options: \\n\
48 path: '/etc/grafana/dashboards/ceph-dashboard'" >> ${DASHBOARD_PROVISIONING}
49
50
51 sudo buildah copy $(CONTAINER) ${DASHBOARD_PROVISIONING} /etc/grafana/provisioning/dashboards/${DASHBOARD_PROVISIONING}
52
53 # expose tcp/3000 for grafana
54 sudo buildah config --port 3000 $(CONTAINER)
55
56 # set working dir
57 sudo buildah config --workingdir /usr/share/grafana $(CONTAINER)
58
59 # set environment overrides from the default locations in /usr/share
60 sudo buildah config --env GF_PATHS_LOGS="/var/log/grafana" $(CONTAINER)
61 sudo buildah config --env GF_PATHS_PLUGINS="/var/lib/grafana/plugins" $(CONTAINER)
62 sudo buildah config --env GF_PATHS_PROVISIONING="/etc/grafana/provisioning" $(CONTAINER)
63 sudo buildah config --env GF_PATHS_DATA="/var/lib/grafana" $(CONTAINER)
64
65 # entrypoint
66 sudo buildah config --entrypoint "grafana-server --config=${GF_CONFIG}" $(CONTAINER)
67
68 # finalize
69 sudo buildah config --label maintainer="Paul Cuzner <pcuzner@redhat.com>" $(CONTAINER)
70 sudo buildah config --label description="Ceph Grafana Container" $(CONTAINER)
71 sudo buildah config --label summary="Grafana Container configured for Ceph mgr/dashboard integration" $(CONTAINER)
72 sudo buildah commit --format docker --squash $(CONTAINER) $(LOCALTAG)
73
74 push:
75 sudo podman tag ${LOCALTAG} quay.io/${TAG}
76 # sudo podman has issues with auth.json; just override it
77 sudo podman login --authfile=auth.json -u $(CONTAINER_REPO_USERNAME) -p $(CONTAINER_REPO_PASSWORD) quay.io
78 sudo podman push --authfile=auth.json --format v2s2 quay.io/${TAG}
79
80 clean:
81 sudo podman rmi ${LOCALTAG} || true
82 sudo podman rmi quay.io/${TAG} || true
83 rm -f grafana-*.rpm* auth.json
84 rm -f ${DASHBOARD_PROVISIONING}