From 43acccc0af8b97003c12426380925cbf102e4080 Mon Sep 17 00:00:00 2001 From: Jerome Petazzoni Date: Thu, 1 Nov 2018 15:35:09 -0500 Subject: [PATCH] Add command to preinstall Helm and Prometheus In some cases, I would like Prometheus to be pre-installed (so that it shows a bunch of metrics) without relying on people doing it (and setting up Helm correctly). This patch allows to run: ./workshopctl helmprom TAG It will setup Helm with a proper service account, then deploy the Pormetheus chart, disabling the alert manager, persistence, and assigning the Prometheus server to NodePort 30090. This command is idempotent. --- prepare-vms/lib/commands.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/prepare-vms/lib/commands.sh b/prepare-vms/lib/commands.sh index 02a959dd..f63cdb08 100644 --- a/prepare-vms/lib/commands.sh +++ b/prepare-vms/lib/commands.sh @@ -400,6 +400,28 @@ _cmd_test() { test_tag } +_cmd helmprom "Install Helm and Prometheus" +_cmd_helmprom() { + TAG=$1 + need_tag + pssh " + if grep -q node1 /tmp/node; then + kubectl -n kube-system get serviceaccount helm || + kubectl -n kube-system create serviceaccount helm + helm init --service-account helm + kubectl get clusterrolebinding helm-can-do-everything || + kubectl create clusterrolebinding helm-can-do-everything \ + --clusterrole=cluster-admin \ + --serviceaccount=kube-system:helm + helm upgrade --install prometheus stable/prometheus \ + --namespace kube-system \ + --set server.service.type=NodePort \ + --set server.service.nodePort=30090 \ + --set server.persistentVolume.enabled=false \ + --set alertmanager.enabled=false + fi" +} + # Sometimes, weave fails to come up on some nodes. # Symptom: the pods on a node are unreachable (they don't even ping). # Remedy: wipe out Weave state and delete weave pod on that node.