#!/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=sonatype-nexus" -o jsonpath='{..status.conditions[?(@.type=="Ready")].status}') done } __expose_pod() { # kill any previous proxy kill $(ps aux | grep '8280[:]8080' | awk '{print $2}') kill $(ps aux | grep '8281[:]8081' | awk '{print $2}') # print admin password echo "HOST: http://192.168.1.194:8280 USERNAME: admin PASSWORD: admin123" # expose export POD_NAME=$(kubectl get pods --namespace demo-infra -l "app=sonatype-nexus" -o jsonpath="{.items[0].metadata.name}") kubectl --namespace demo-infra port-forward $POD_NAME 8280:8080 --address 0.0.0.0 & kubectl --namespace demo-infra port-forward $POD_NAME 8281:8081 --address 0.0.0.0 & } POD_STATUS=$(kubectl get pods --namespace demo-infra -l "app=sonatype-nexus" -o jsonpath='{..status.conditions[?(@.type=="Ready")].status}') if [ "$POD_STATUS" = 'True' ]; then echo "pod already installed, exposing it..." # create proxy into the pod __expose_pod else echo "pod missing, installing it..." # install nexus helm install -f values.yaml --namespace demo-infra --kubeconfig ~/.kube/config demo-infra-nexus ./ # wait for it to become ready __is_pod_ready # create proxy into the pod __expose_pod fi