diff --git a/demo-infra-nexus-install.sh b/demo-infra-nexus-install.sh index ec11d50cb433b23890992780ac0f30592f1d17ac..0373e2af56345c46cac0ba0dd806b738d2a64bbd 100644 --- a/demo-infra-nexus-install.sh +++ b/demo-infra-nexus-install.sh @@ -1,26 +1,46 @@ #!/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-nexus" -o jsonpath='{..status.conditions[?(@.type=="Ready")].status}') + POD_STATUS=$(kubectl get pods --namespace demo-infra -l "app=sonatype-nexus" -o jsonpath='{..status.conditions[?(@.type=="Ready")].status}') done } -# install nexus -helm install -f values.yaml --namespace demo-infra --kubeconfig ~/.kube/config demo-infra-nexus oteemo.github.io/charts/sonatype-nexus +__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 + # 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: admin123" + # create proxy into the pod + __expose_pod -# 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 & +fi diff --git a/demo-infra-nexus-uninstall.sh b/demo-infra-nexus-uninstall.sh index b798edf88d01101210fb0074b487652fe3952d9b..ba3bdb49e84dde73208df61213217f23910e33fc 100644 --- a/demo-infra-nexus-uninstall.sh +++ b/demo-infra-nexus-uninstall.sh @@ -1,4 +1,8 @@ #!/bin/sh +# remove proxy +kill $(ps aux | grep '8280[:]8080' | awk '{print $2}') +kill $(ps aux | grep '8281[:]8081' | awk '{print $2}') + # use helm for uninstall -helm uninstall --namespace demo-infra --kubeconfig ~/.kube/config demo-infra-jenkins +helm uninstall --namespace demo-infra --kubeconfig ~/.kube/config demo-infra-nexus diff --git a/values.yaml b/values.yaml index 2f27f22abe43c0e995e9ea407291eb7004785eba..3db8ba44c5a310b49091852d87ad10f6552a7f61 100644 --- a/values.yaml +++ b/values.yaml @@ -10,7 +10,7 @@ deploymentStrategy: {} nexus: imageName: quay.io/travelaudience/docker-nexus - imageTag: 3.21.2-03 + imageTag: 3.22.0-02 imagePullPolicy: IfNotPresent # Uncomment this to scheduler pods on priority # priorityClassName: "high-priority" @@ -19,6 +19,8 @@ nexus: value: "-Xms1200M -Xmx1200M -XX:MaxDirectMemorySize=2G -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap" - name: NEXUS_SECURITY_RANDOMPASSWORD value: "false" + - name: NEXUS_CONTEXT + value: "nexus" # nodeSelector: # cloud.google.com/gke-nodepool: default-pool resources: {} @@ -59,13 +61,13 @@ nexus: periodSeconds: 30 failureThreshold: 6 # timeoutSeconds: 10 - path: / + path: /nexus readinessProbe: initialDelaySeconds: 30 periodSeconds: 30 failureThreshold: 6 # timeoutSeconds: 10 - path: / + path: /nexus # hostAliases allows the modification of the hosts file inside a container hostAliases: [] # - ip: "192.168.1.10" @@ -92,7 +94,7 @@ nexusProxy: # labels: {} env: nexusDockerHost: - nexusHttpHost: + nexusHttpHost: www.joaolino.com enforceHttps: false cloudIamAuthEnabled: false ## If cloudIamAuthEnabled is set to true uncomment the variables below and remove this line @@ -113,7 +115,7 @@ nexusProxy: # memory: 512Mi nexusProxyRoute: - enabled: true + enabled: false labels: annotations: path: /nexus