Skip to content

PMM-14072 Automate Grafana plugin upgrade #1687

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

Open
wants to merge 7 commits into
base: v3
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,12 @@ docker_clean:
docker-compose stop \
&& docker-compose rm -f -v \
&& docker system prune --volumes -f

.PHONY: upgrade_plugins
upgrade_plugins:
@echo "Upgrading PMM plugins..."
@echo "To override the platform, set the PLATFORM environment variable."
@echo "Example: PLATFORM=linux/arm64 make upgrade_plugins"
@echo
@cd misc && \
./upgrade-plugins.sh
9 changes: 9 additions & 0 deletions misc/Dockerfile.upgrade
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ARG IMAGE_VERSION=grafana/grafana:latest
FROM ${IMAGE_VERSION}

USER root

# No need to run the server, we want to exit after the upgrade
RUN sed -i '/exec grafana server/,$d' /run.sh

USER grafana
23 changes: 23 additions & 0 deletions misc/upgrade-plugins.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash -ex

declare PLATFORM=${PLATFORM:-linux/amd64}
declare DIR
DIR=$(realpath ../panels)

# Note: the PLATFORM matters because some plugins are built for a specific architecture.
docker buildx build --platform="$PLATFORM" --progress=plain -t local/grafana -f Dockerfile.upgrade .

rm -rf "${DIR:?}"/*

docker run \
--rm -t \
--name grafana \
--platform="$PLATFORM" \
-e GF_INSTALL_PLUGINS=grafana-clickhouse-datasource,grafana-polystat-panel,jdbranham-diagram-panel \
-v "${DIR}":/var/lib/grafana/plugins \
local/grafana

echo "Listing upgraded Grafana plugins..."
ls -l "$DIR"

docker rmi local/grafana
Loading