Skip to content

Instantly share code, notes, and snippets.

@pramine
Forked from vfarcic/jenkins-setup.sh
Created May 30, 2021 23:39
Show Gist options
  • Select an option

  • Save pramine/8caea0dd6798c9eb9a2926b207d935b1 to your computer and use it in GitHub Desktop.

Select an option

Save pramine/8caea0dd6798c9eb9a2926b207d935b1 to your computer and use it in GitHub Desktop.

Revisions

  1. @vfarcic vfarcic created this gist May 16, 2021.
    60 changes: 60 additions & 0 deletions jenkins-setup.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,60 @@
    # Create a Kubernetes cluster with NGINX Ingress

    # If NOT EKS
    export INGRESS_HOST=$(kubectl \
    --namespace ingress-nginx \
    get svc ingress-nginx-controller \
    --output jsonpath="{.status.loadBalancer.ingress[0].ip}")

    # If EKS
    export INGRESS_HOSTNAME=$(kubectl \
    --namespace ingress-nginx \
    get svc ingress-nginx-controller \
    --output jsonpath="{.status.loadBalancer.ingress[0].hostname}")

    # If EKS
    export INGRESS_HOST=$(\
    dig +short $INGRESS_HOSTNAME)

    echo $INGRESS_HOST

    # Repeat the `export` commands if the output is empty

    # If the output contains more than one IP, wait for a while longer, and repeat the `export` commands.

    # If the output continues having more than one IP, choose one of them and execute `export INGRESS_HOST=[...]` with `[...]` being the selected IP.

    helm repo add jenkinsci https://charts.jenkins.io

    helm repo update

    echo "controller:
    ingress:
    enabled: true
    apiVersion: networking.k8s.io/v1
    hostName: jenkins.$INGRESS_HOST.nip.io
    installPlugins:
    - kubernetes:1.29.4
    - workflow-aggregator:2.6
    - git:4.7.1
    - configuration-as-code:1.51
    - blueocean:1.24.6
    " | tee jenkins-values.yaml

    helm upgrade --install \
    jenkins jenkinsci/jenkins \
    --namespace jenkins \
    --create-namespace \
    --values jenkins-values.yaml \
    --wait

    echo http://jenkins.$INGRESS_HOST.nip.io

    # Open it in browser

    # Use `admin` as the Username and the output from the command below as the Password

    kubectl --namespace jenkins \
    get secret jenkins \
    --output jsonpath="{.data.jenkins-admin-password}" \
    | base64 --decode && echo