{"id":14984800,"url":"https://github.com/eamonkeane/jenkins-blue","last_synced_at":"2025-10-30T03:42:51.354Z","repository":{"id":217144704,"uuid":"122255787","full_name":"EamonKeane/jenkins-blue","owner":"EamonKeane","description":"Quickly provision jenkins blue ocean on kubernetes with persistent configuration","archived":false,"fork":false,"pushed_at":"2018-03-07T11:35:38.000Z","size":1751,"stargazers_count":20,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T19:22:18.273Z","etag":null,"topics":["cert-manager","cicd","helm","hetzner-cloud","jenkins-blue-ocean","jenkins-pipeline","jenkinsfile","kubeadm","kubernetes","kubernetes-bare-metal","nginx-ingress","pipline-library","quay","ubuntu1604"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EamonKeane.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-02-20T21:02:05.000Z","updated_at":"2020-02-11T03:35:12.000Z","dependencies_parsed_at":"2024-01-14T20:53:19.828Z","dependency_job_id":null,"html_url":"https://github.com/EamonKeane/jenkins-blue","commit_stats":null,"previous_names":["eamonkeane/jenkins-blue"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EamonKeane%2Fjenkins-blue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EamonKeane%2Fjenkins-blue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EamonKeane%2Fjenkins-blue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EamonKeane%2Fjenkins-blue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EamonKeane","download_url":"https://codeload.github.com/EamonKeane/jenkins-blue/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248311668,"owners_count":21082630,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cert-manager","cicd","helm","hetzner-cloud","jenkins-blue-ocean","jenkins-pipeline","jenkinsfile","kubeadm","kubernetes","kubernetes-bare-metal","nginx-ingress","pipline-library","quay","ubuntu1604"],"created_at":"2024-09-24T14:09:41.324Z","updated_at":"2025-10-30T03:42:51.278Z","avatar_url":"https://github.com/EamonKeane.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jenkins Blue Ocean Kubernetes Ubuntu 16.04\nQuickly provision Jenkins blue ocean on kubernetes v1.9 with RBAC and with persistent configuration.\nGo from a simple 16.04 VM to a portable, scalable CI-CD pipeline on kubernetes with automated SSL provisioned and automatic building on push to github. The tutorial takes around 20 minutes. \nThe Jenkins instance can be deleted and moved between clouds while retaining the job configuration via the excellent Jenkins Helm chart ```https://github.com/kubernetes/charts/tree/master/stable/jenkins```.\n\nThe example shown will use a single Hetzner server ($0.04/hour), but this first step can skipped, and ssh access to an ubuntu 16.04 machine can be used instead.\n\nThe sample CI-CD pipeline and application uses Lachlan Evanson's excellent croc-hunter tutorial, which I would encourage you to go through after this. \nhttps://github.com/lachie83/croc-hunter\n\nInspiration was also taken from Nick Johnson's excellent upcoming book 'Continuous Deployment with Kubernetes' (https://withku.be/)\n\n* Asciicast with all commands run below is here (tokens shown in asciicast have been revoked):\n[![asciicast](https://asciinema.org/a/5g5tbqwFObfUqDHhMr13lXUCm.png)](https://asciinema.org/a/5g5tbqwFObfUqDHhMr13lXUCm)\n\n# Checkout repository\n```bash\ngit clone https://github.com/EamonKeane/jenkins-blue.git\n```\n```bash\ncd jenkins-blue\n```\n\n# Setup with Hetzner Cloud\n\n1. Register on Hetzner (https://www.hetzner.com/cloud)\n2. Get API token from dashboard\n3. Install hcloud cli: ```brew install hetznercloud/tap/hcloud``` (https://github.com/hetznercloud/cli)\n4. ```hcloud ssh-key create --name $KEY_NAME --public-key-from-file ~/.ssh/id_rsa.pub```\n5. ```hcloud context create jenkins-blue-ocean```. Enter token when prompted\n6. Note your ssh-key ID returned from: ```hcloud ssh-key list```\n\n```bash\nSERVER_NAME=jenkins-blue-ocean # replace this with your preferred name\n```\n```bash\nSSH_KEY=7170 #replace with your ssh-key id here\n```\n```bash\nSERVER_TYPE=cx41 # Machine with 16GB of ram, 4 vCPU, 160 GB disk (no commitment, $25 per month, 80% less than t2.xlarge on EC2)\n```\n\nTo install a single node kubeadm on hetzner run (this will take around 4 minutes):\nhttps://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/\n```bash\n./kubernetes-hetzner.sh --SERVER_NAME=$SERVER_NAME --ssh-key=$SSH_KEY --SERVER_TYPE=$SERVER_TYPE\n```\nSet the jenkins ip variable:\n```bash\nJENKINS_IP=$(hcloud server list | grep -E $SERVER_NAME | grep -oE \"\\b([0-9]{1,3}\\.){3}[0-9]{1,3}\\b\");echo $JENKINS_IP\n```\n# With ssh access to an ubuntu 16.04 machine\n```bash\nSSH_USER=root\n```\n```bash\nJENKINS_IP=00.00.00.00 #Enter your machine IP here\n```\n\nTo install a single node kubernetes kubeadm cluster run (this will take around 4 minutes):\n(kubernetes install commands from: https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/)\n```bash\n./kubernetes-ubuntu1604.sh --SSH_USER=$SSH_USER --JENKINS_IP=$JENKINS_IP\n```\n\n# Create DNS A-record\n* Create a DNS A-record with the IP address of ```$JENKINS_IP```\n```bash\nJENKINS_URL=jenkins.mysite.io # replace with your jenkins url\n```\n* Create a DNS A-record with the IP address for croc-hunter:\n```bash\nCROC_HUNTER_URL=croc-hunter.mysite.io # replace with your croc-hunter url\n```\n* Confirm that the ```$JENKINS_IP``` record exists at ```$JENKINS_URL``` (this may take a minute or two depending on your DNS provider)\n```bash\nwatch -n 5 dig $JENKINS_URL\n```\n![](docs/dig_jenkins_url.png)\n* Confirm that the ```$CROC_HUNTER_URL``` record exists at ```$JENKINS_URL``` (this may take a minute or two depending on your DNS provider)\n```bash\nwatch -n 5 dig $CROC_HUNTER_URL\n```\n\n\n# Fork the croc-hunter repo with example application\nThis contains a lot of best practice and contains a Jenkinsfile which is required to demonstrate Blue Ocean functionality. Alternatively specify your own project which has a Jenkinsfile.\n```https://github.com/lachie83/croc-hunter/```\n* Make a private image repository (e.g. on Quay.io or Docker Hub e.g quay.io/eamonkeane/croc-hunter)\n* Fork the following repository on github.com:\n```text\nhttps://github.com/EamonKeane/croc-hunter\n```\nReturning to the shell, run the following commands:\n```bash\nORGANISATION=EamonKeane # enter your organisation (github username)\n```\n```bash\ncd ..\n```\n```bash\ngit clone https://github.com/$ORGANISATION/croc-hunter.git\n```\n```bash\ncd croc-hunter\n```\n```bash\nIMAGE_REPOSITORY_ORGANISATION=eamonkeane\n```\n```bash\nIMAGE_REPOSITORY_URL=quay.io/eamonkeane/croc-hunter\n```\nUpdate the values for croc-hunter to match your values (```brew install jq```)\n```bash\njq \".app.hostname = \\\"$CROC_HUNTER_URL\\\"\" Jenkinsfile.json \u003e tmp.json \u0026\u0026 mv tmp.json Jenkinsfile.json\n```\n```bash\njq \".container_repo.master_acct = \\\"$IMAGE_REPOSITORY_ORGANISATION\\\"\" Jenkinsfile.json \u003e tmp.json \u0026\u0026 mv tmp.json Jenkinsfile.json\n```\n```bash\njq \".container_repo.image = \\\"$IMAGE_REPOSITORY_URL\\\"\" Jenkinsfile.json \u003e tmp.json \u0026\u0026 mv tmp.json Jenkinsfile.json\n```\n* Commit the changes to your croc-hunter fork.\n```bash\ngit add -A; git commit -m \"changed croc hunter url and image repo\"; git push origin master\n```\n\n# Install jenkins to configure jobs and retrieve secrets\nPrerequisites:\n* ```brew install kubectl``` (\u003e= version 1.9.3)\n* ```brew install kubernetes-helm``` (\u003e= version 2.8.1)\n\n# Export the kubectl config copied from the kubeadm machine:\n```bash\ncd ../jenkins-blue\nexport KUBECONFIG=$PWD/admin.conf\n```\n\n# Create kubernetes image pull secret for croc-hunter\n```bash\nDOCKER_SERVER=quay.io\n```\n```bash\nDOCKER_USERNAME=eamonkeane+crochunter\n```\n```bash\nDOCKER_PASSWORD=\n```\n```bash\nDOCKER_EMAIL=. # This is not important and can be left as a dot\n```\n```bash\nkubectl create namespace croc-hunter\n```\n```bash\nkubectl create secret docker-registry croc-hunter-secrets --namespace=croc-hunter --docker-server=$DOCKER_SERVER --docker-username=$DOCKER_USERNAME --docker-password=$DOCKER_PASSWORD --docker-email=$DOCKER_EMAIL\n```\n\n# Jenkins Installation and Configuration\nReplace your jenkins url in the hostname, TLS secret name, and TLS secret sections of jenkins-values-initial.yaml and jenkins-values.yaml\n* (sed commands shown for mac gnu BSD - on linux replace the two instances in this Readme.md and one in jenkins-initial-install of sed -i '' with sed -i'' https://stackoverflow.com/questions/4247068/sed-command-with-i-option-failing-on-mac-but-works-on-linux)\n```bash\nsed -i '' -e \"s/jenkins\\.mysite\\.io/$JENKINS_URL/g\" jenkins-values.yaml\n```\n```bash\nsed -i '' -e \"s/jenkins\\.mysite\\.io/$JENKINS_URL/g\" jenkins-values-initial.yaml\n```\n\nInitial temporary installation of jenkins. This takes approx 4 minutes. This also installs nginx-ingress (configured for bare metal) and cert-manager (configured to auto-provision SSL certs) :\n```bash\n./jenkins-initial-install.sh \n```\n\n* Go to Jenkins url at: \n```bash\necho https://$JENKINS_URL\n```\n* Print out jenkins password:\n```bash\nprintf $(kubectl get secret --namespace jenkins jenkins-jenkins -o jsonpath=\"{.data.jenkins-admin-password}\" | base64 --decode);echo\n```\n* Enter username ```admin``` and password from terminal\n\n* Add docker credentials to jenkins:\n1. Click on Credentials\n2. Click on Jenkins link\n3. Click on Global Credentials\n4. Click add credentials\n5. Select Username  and password\n6. Enter ```$DOCKER_USERNAME``` and ```$DOCKER_PASSWORD``` as above\n7. Enter ID as quay_creds\n8. Enter description as your choice e.g. croc-hunter-quay-creds\n9. Press OK\n\n* Configure Jenkins pipeline to talk to croc-hunter\n1. Click on Jenkins Blue Ocean in side bar on home page\n2. Click on Create Pipeline\n3. Click on Github\n4. Click on 'create an access key here'\n5. Login to Github, enter token name, click generate token, copy token to clipboard\n6. Paste token into jenkins and click connect\n7. Select organisation and croc-hunter repo\n\n\n# Add github webhook\n* Create a token on github with access to read/write repo hooks\n* Go to ```Github.com```, click on ```settings```, then ```developer settings```, then ```personal access tokens```, then ```generate new token```, tick read/write admin hooks, click generate token and copy to clipboard\n* Set your github details:\n```bash\nAUTH_TOKEN= #put your github API token here\n```\n```bash\nORGANISATION=EamonKeane #replace this with your github username or organisation\n```\n```bash\nREPOSITORY=croc-hunter #replace this with your github repo if not using croc-hunter\n```\n\n```bash\ngithub-webhook/create-github-webhook.sh --AUTH_TOKEN=$AUTH_TOKEN --SERVICE_URL=$JENKINS_URL --ORGANISATION=$ORGANISATION --REPOSITORY=$REPOSITORY\n```\n\n# Verify the application deploys\nClick on the master branch on Jenkins blue ocean. After approximately 5 minutes, the application and test will have completed. \nThe croc-hunter application will be available on ```https://$CROC_HUNTER_URL```\n* Jenkins Blue Ocean Master Branch:\n![](docs/croc-hunter-master-branch.png)\n* ```https://$CROC_HUNTER_URL```\n![](docs/croc-hunter-release.png)\n\n# Copy jenkins configuration\n```bash\n./copy-jenkins-config.sh\n```\n\n# Persist Jenkins data in helm chart\n* Paste the following below the data section in jenkins/templates/config.yaml which will populate when helm installs:\n```text\n  {{- $files := .Files }}\n  {{- range tuple \"blue-ocean-config.xml\" }}\n  {{ . }}: |-\n    {{ $files.Get . }}\n  {{- end }}\n```\n![](docs/jenkins-config.png)\n\n\n* Copy the below two lines directly under apply_confg.sh into jenkins/templates/config.yaml. The new lines will become lines 149 and 150:\n```text\n    mkdir -p /var/jenkins_home/users/admin/;\n    cp -n /var/jenkins_config/blue_ocean_credentials.xml /var/jenkins_home/users/admin/config.xml;\n```\n![](docs/copy-configuration-applysh.png)\n\n* Copy the contents of jenkins-jobs/croc-hunter/config.xml to jenkins-jobs.yaml by using the following commands:\n```bash\necho \"    croc-hunter: |-\" \u003e\u003e jenkins-jobs.yaml\n```\n```bash\ncat jenkins-jobs/croc-hunter/config.xml | sed 's/^/      /' \u003e\u003e jenkins-jobs.yaml\n```\n\nThe jenkins-jobs.yaml should look like the below\n```text\nMaster:\n  Jobs: |-\n    croc-hunter: |-\n      \u003c?xml version='1.0' encoding='UTF-8'?\u003e\n```\n![](docs/copy-jenkins-job.png)\n\n# Nuke the jenkins installation\n```bash\nhelm del --purge jenkins\n```\n\n# Install jenkins with values persisted\n* Create the persistent volume and persistent volume claim\n```bash\nkubectl create -f kubernetes-yaml/jenkins-pv.yaml\n```\n```bash\nkubectl create -f kubernetes-yaml/jenkins-pvc.yaml\n```\n\n* Check that the persistent volume claim is bound:\n```bash\nkubectl get pvc -n jenkins\n```\n![](docs/jenkins-pvc.png)\n* Install jenkins. Installation takes around 120 seconds (mostly due to jenkins startup time)\n```bash\nhelm upgrade --install --namespace jenkins --wait --values jenkins-values.yaml --values jenkins-jobs.yaml jenkins jenkins/\n```\n\n# Make a change to croc-hunter repository\n```bash\ncd ../croc-hunter\n```\n```bash\necho \"change -- ignore\" \u003e\u003e README.md\n```\n```bash\ngit add -A; git commit -m \"made change to README.md\"; git push origin master\n```\n\n# Login to jenkins\n* Print out jenkins password:\n```bash\nprintf $(kubectl get secret --namespace jenkins jenkins-jenkins -o jsonpath=\"{.data.jenkins-admin-password}\" | base64 --decode);echo\n```\n* Go to Jenkins url at: ```https://$JENKINS_URL```\n* Enter username ```admin``` and password from clipboard\n\n* Check that the docker credentials quay_creds has been persisted in the credentials section.\n\nClick on Jenkins blue ocean and you will now see master building and the croc-hunter app will update.\n\n# Tidying up\n```bash\nhcloud server delete $SERVER_NAME\n```\nDelete github API tokens and keys from bash history or from github.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feamonkeane%2Fjenkins-blue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feamonkeane%2Fjenkins-blue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feamonkeane%2Fjenkins-blue/lists"}