From 1492f22faaa0ee3597037c185108de23907fc1c6 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Thu, 11 Mar 2021 15:03:44 -0800 Subject: [PATCH] Use grafyaml container image Instead of building a local grafana image with grafyaml installed, use the plain upstream grafana image along with the newly created separate opendev grafyaml image to run the dashboards. Depends-On: https://review.opendev.org/780119 Change-Id: If0d584f848f213aeea385885e3decfaee6303de5 --- docker/grafana/Dockerfile | 26 ------------------ docker/grafana/update-grafana | 11 -------- playbooks/roles/grafana/tasks/main.yaml | 17 +++++++++--- .../grafana/templates/docker-compose.yaml.j2 | 3 +-- .../roles/grafana/templates/grafyaml.env.j2 | 1 + zuul.d/docker-images/grafana.yaml | 27 ------------------- zuul.d/project.yaml | 9 ------- zuul.d/system-config-run.yaml | 3 +-- 8 files changed, 16 insertions(+), 81 deletions(-) delete mode 100644 docker/grafana/Dockerfile delete mode 100644 docker/grafana/update-grafana create mode 100644 playbooks/roles/grafana/templates/grafyaml.env.j2 delete mode 100644 zuul.d/docker-images/grafana.yaml diff --git a/docker/grafana/Dockerfile b/docker/grafana/Dockerfile deleted file mode 100644 index 78a24b637d..0000000000 --- a/docker/grafana/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (c) 2020 Red Hat, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -FROM docker.io/grafana/grafana:7.4.2-ubuntu - -LABEL maintainer="infra-root@openstack.org" - -USER root -RUN apt-get update && apt-get install -y python3-pip \ - && rm -rf /var/lib/apt/lists/* -RUN pip3 install grafyaml - -COPY update-grafana /usr/local/bin -RUN chmod a+x /usr/local/bin/update-grafana diff --git a/docker/grafana/update-grafana b/docker/grafana/update-grafana deleted file mode 100644 index 1d18cabd31..0000000000 --- a/docker/grafana/update-grafana +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -# -# Refresh grafana dashboards from project-config -# - -GF_USER="$(cat /etc/grafana/secrets/admin_user)" -GF_PASSWORD="$(cat /etc/grafana/secrets/admin_password)" -GF_URL="http://${GF_USER}:${GF_PASSWORD}@localhost:3000/" - -grafana-dashboard --debug --grafana-url="${GF_URL}" update /opt/project-config/grafana diff --git a/playbooks/roles/grafana/tasks/main.yaml b/playbooks/roles/grafana/tasks/main.yaml index a811141c22..65accea050 100644 --- a/playbooks/roles/grafana/tasks/main.yaml +++ b/playbooks/roles/grafana/tasks/main.yaml @@ -33,6 +33,14 @@ content: '{{ grafana_secret_key }}' dest: /etc/grafana/secrets/secret_key +- name: Write grafyaml env file + template: + src: grafyaml.env.j2 + dest: /etc/grafana/secrets/grafyaml.env + owner: root + group: root + mode: 0644 + - name: Install apache2 apt: name: @@ -81,7 +89,8 @@ - name: Import dashboards to container shell: - cmd: | - docker-compose exec -T grafana /usr/local/bin/update-grafana - chdir: /etc/grafana-docker/ - + cmd: >- + docker run --rm -t --network=host + --env-file /etc/grafana/secrets/grafyaml.env + -v /opt/project-config/grafana:/grafana:ro + opendevorg/grafyaml diff --git a/playbooks/roles/grafana/templates/docker-compose.yaml.j2 b/playbooks/roles/grafana/templates/docker-compose.yaml.j2 index 36dff6400d..cbddcec090 100644 --- a/playbooks/roles/grafana/templates/docker-compose.yaml.j2 +++ b/playbooks/roles/grafana/templates/docker-compose.yaml.j2 @@ -5,7 +5,7 @@ version: '2' services: grafana: restart: always - image: docker.io/opendevorg/grafana + image: docker.io/grafana/grafana:7.4.2-ubuntu network_mode: host environment: GF_SECURITY_ADMIN_PASSWORD__FILE: '/etc/grafana/secrets/admin_password' @@ -14,5 +14,4 @@ services: GF_AUTH_ANONYMOUS_ENABLED: 'true' GF_USERS_ALLOW_SIGN_UP: 'false' volumes: - - /opt/project-config:/opt/project-config - /etc/grafana/secrets:/etc/grafana/secrets diff --git a/playbooks/roles/grafana/templates/grafyaml.env.j2 b/playbooks/roles/grafana/templates/grafyaml.env.j2 new file mode 100644 index 0000000000..0509c4bfd3 --- /dev/null +++ b/playbooks/roles/grafana/templates/grafyaml.env.j2 @@ -0,0 +1 @@ +GRAFANA_URL=http://{{ grafana_admin_user }}:{{ grafana_admin_password }}@localhost:3000/ diff --git a/zuul.d/docker-images/grafana.yaml b/zuul.d/docker-images/grafana.yaml deleted file mode 100644 index 9586a86073..0000000000 --- a/zuul.d/docker-images/grafana.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# Grafana jobs -- job: - name: system-config-build-image-grafana - description: Build a grafana/grafyaml image. - provides: grafana-container-image - parent: system-config-build-image - vars: &grafana_vars - docker_images: - - context: docker/grafana - repository: opendevorg/grafana - files: &grafana_files - - docker/grafana/ - -- job: - name: system-config-upload-image-grafana - description: Build and upload a grafana image. - provides: grafana-container-image - parent: system-config-upload-image - vars: *grafana_vars - files: *grafana_files - -- job: - name: system-config-promote-image-grafana - description: Promote a previously published grafana image to latest. - parent: system-config-promote-image - vars: *grafana_vars - files: *grafana_files diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index 3f3ef66e2d..328dee4992 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -58,8 +58,6 @@ - system-config-run-grafana: dependencies: - name: opendev-buildset-registry - - name: system-config-build-image-grafana - soft: true - system-config-run-graphite - system-config-run-keycloak - system-config-run-review-3.3: @@ -119,7 +117,6 @@ - name: opendev-buildset-registry - name: system-config-build-image-assets soft: true - - system-config-build-image-grafana - system-config-build-image-haproxy-statsd: dependencies: - name: opendev-buildset-registry @@ -219,8 +216,6 @@ - system-config-run-grafana: dependencies: - name: opendev-buildset-registry - - name: system-config-upload-image-grafana - soft: true - system-config-run-graphite - system-config-run-keycloak - system-config-run-review-3.3: @@ -268,7 +263,6 @@ - name: opendev-buildset-registry - name: system-config-upload-image-assets soft: true - - system-config-upload-image-grafana - system-config-upload-image-refstack - system-config-upload-image-haproxy-statsd: dependencies: @@ -323,7 +317,6 @@ - system-config-promote-image-jinja-init - system-config-promote-image-gitea-init - system-config-promote-image-gitea - - system-config-promote-image-grafana - system-config-promote-image-etherpad - system-config-promote-image-haproxy-statsd - system-config-promote-image-zookeeper-statsd @@ -498,8 +491,6 @@ soft: true - name: infra-prod-letsencrypt soft: true - - name: system-config-promote-image-grafana - soft: true - infra-prod-service-mirror: &infra-prod-service-mirror dependencies: - name: infra-prod-letsencrypt diff --git a/zuul.d/system-config-run.yaml b/zuul.d/system-config-run.yaml index 6ca7d3cdae..e8e4f9ba21 100644 --- a/zuul.d/system-config-run.yaml +++ b/zuul.d/system-config-run.yaml @@ -645,7 +645,7 @@ description: | Run the playbook for the etherpad servers. timeout: 3600 - requires: grafana-container-image + requires: grafyaml-container-image required-projects: - opendev/system-config - openstack/project-config @@ -667,7 +667,6 @@ - playbooks/roles/grafana/ - playbooks/roles/install-docker/ - playbooks/roles/pip3/ - - docker/grafana/ - testinfra/test_grafana.py - job: