From 99e921f4afbd3428e034fe6b59519765a1e16acc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lino?= Date: Wed, 15 Apr 2020 09:05:49 +0000 Subject: [PATCH] Add install and uninstall scripts to make operation straightforward. --- demo-infra-jenkins-install.sh | 28 ++++++++++++++++++++++++++++ demo-infra-jenkins-uninstall.sh | 4 ++++ 2 files changed, 32 insertions(+) create mode 100644 demo-infra-jenkins-install.sh create mode 100644 demo-infra-jenkins-uninstall.sh diff --git a/demo-infra-jenkins-install.sh b/demo-infra-jenkins-install.sh new file mode 100644 index 0000000..8ac6894 --- /dev/null +++ b/demo-infra-jenkins-install.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +__is_pod_ready() { + + POD_STATUS="False" + while [ "$POD_STATUS" != "True" ]; + do + echo "waiting for pod..." + sleep 5 + POD_STATUS=$(kubectl get pods --namespace demo-infra -l "app.kubernetes.io/component=jenkins-master" -l "app.kubernetes.io/instance=demo-infra-jenkins" -o jsonpath='{..status.conditions[?(@.type=="Ready")].status}') + done +} + +# install jenkins +helm install --namespace demo-infra --kubeconfig ~/.kube/config demo-infra-jenkins stable/jenkins + +# wait for it to become ready +__is_pod_ready + +# print admin password +export JENKINS_PASS=$(kubectl get secret --namespace demo-infra demo-infra-jenkins -o jsonpath="{.data.jenkins-admin-password}" | base64 --decode) +echo "HOST: http://192.168.1.194:8180 USERNAME: admin PASSWORD: $JENKINS_PASS" + +# expose +export POD_NAME=$(kubectl get pods --namespace demo-infra -l "app.kubernetes.io/component=jenkins-master" -l "app.kubernetes.io/instance=demo-infra-jenkins" -o jsonpath="{.items[0].metadata.name}") +kubectl --namespace demo-infra port-forward $POD_NAME 8180:8080 --address 0.0.0.0 & + +#helm uninstall --namespace demo-infra --kubeconfig ~/.kube/config demo-infra-jenkins diff --git a/demo-infra-jenkins-uninstall.sh b/demo-infra-jenkins-uninstall.sh new file mode 100644 index 0000000..b798edf --- /dev/null +++ b/demo-infra-jenkins-uninstall.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# use helm for uninstall +helm uninstall --namespace demo-infra --kubeconfig ~/.kube/config demo-infra-jenkins -- 2.24.1