From 4ed4818ddf7985abee6104c533048eb953e30d9a Mon Sep 17 00:00:00 2001 From: Bruce Becker Date: Thu, 4 Jan 2024 08:39:05 +0100 Subject: [PATCH] feat/grafana 10 (#83) feat(node-exporter): add a node exporter job fix(github-exporter): bump version fix(github-exporter): use the variable in the artifact string instead of hard-coding it fix(github-exporter): template the secret to be read into the environment fix(jenkins): use vault secret in template fix(grafana): use podman driver BREAKING CHANGE: no longer use the exec driver chore(monitoring): bump versions refactor(monitoring): lookup mysql service in the consul catalog fix(prometheus): fix path to metrics fix(promtail): add nomad job log scraping Signed-off-by: Bruce Becker --------- Signed-off-by: Bruce Becker --- jenkins/jenkins.nomad | 247 ++++++++++++------------ jenkins/jenkins.yml.tmpl | 71 +++++++ monitoring/github-exporter.nomad | 44 +++-- monitoring/grafana.nomad | 52 +++-- monitoring/monitoring.nomad | 178 ++++++++--------- monitoring/templates/grafana.ini.tpl | 10 +- monitoring/templates/prometheus.yml.tpl | 2 +- monitoring/templates/promtail.yml.tpl | 20 ++ node-exporter.nomad | 72 +++++++ 9 files changed, 434 insertions(+), 262 deletions(-) create mode 100644 jenkins/jenkins.yml.tmpl create mode 100644 node-exporter.nomad diff --git a/jenkins/jenkins.nomad b/jenkins/jenkins.nomad index fc84bc6..0923903 100644 --- a/jenkins/jenkins.nomad +++ b/jenkins/jenkins.nomad @@ -1,28 +1,40 @@ +variable "jenkins_war" { + type = map(string) + default = { + war_version = "2.426.2" + war_sha256 = "3731b9f44973fbbf3e535f98a80c21aad9719cb4eea8a1e59e974c11fe846848" #pragma: allowlist secret + } + description = "Version of the Jenkins release to deploy" +} + +variable "plugin_manager" { + type = map(string) + default = { + version = "2.12.8" + } + description = "Map of configuration entries for the java plugin manager." +} + job "jenkins" { update { max_parallel = 1 health_check = "checks" - auto_revert = true + auto_revert = true auto_promote = true - canary = 1 - } - - constraint { - attribute = "${attr.unique.hostname}" - operator = "regexp" - value = "^turing.*" + canary = 1 } datacenters = ["dc1"] + type = "service" - group "main" { + + group "controller" { count = 1 network { - port "ui" { - static = "8080" - } - mode = "host" + port "ui" {} + // mode = "host" + port "agent" {} } volume "casc" { @@ -31,157 +43,150 @@ job "jenkins" { source = "jenkins_casc" } - task "controller" { + task "plugins" { driver = "exec" + env { + CASC_JENKINS_CONFIG = "alloc/data/jenkins.yml" + JENKINS_HOME = "alloc/jenkins" + CACHE_DIR = "local/" + } + lifecycle { + hook = "prestart" + sidecar = false + } volume_mount { volume = "casc" - destination = "/usr/share/jenkins" + destination = "/usr/share/jenkins/" read_only = false } artifact { - source = "https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.12.8/jenkins-plugin-manager-2.12.8.jar" + source = "https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/${var.plugin_manager.version}/jenkins-plugin-manager-${var.plugin_manager.version}.jar" destination = "alloc/data/jenkins-plugin-manager.jar" - mode = "file" + mode = "file" } artifact { - source = "https://get.jenkins.io/war-stable/2.346.1/jenkins.war" + source = "https://get.jenkins.io/war-stable/${var.jenkins_war.war_version}/jenkins.war" destination = "alloc/data/jenkins.war" - mode = "file" + mode = "file" options { - checksum = "sha256:176e2ce5c23d3c0b439befe0461e7ed1f53ac3091db05980198c23c7fde53b27" + checksum = "sha256:${var.jenkins_war.war_sha256}" } } + template { - data = "{{ key \"jenkins/plugins\" }}" - destination = "local/plugins.txt" + data = "{{ key \"nomad/jenkins/plugins\" }}" + destination = "alloc/data/plugins.txt" change_mode = "restart" } - env { - CASC_JENKINS_CONFIG = "alloc/data/jenkins.yml" - JENKINS_HOME = "/usr/share/jenkins" - CACHE_DIR = "local/" - } + template { - data = <