Jenkins Helm Chart for Kubernetes
Kubernetes
,
Helm
,
Jenkins
/
November 04, 2018
Installing Jenkins on Kubernetes for your CI and CD Pipelines sounds like a daunting task until you get to know that you can do that with Helm Charts.
The Helm Chart for Jenkins is avilable here .
Installation
First you need to specify your overrides in a YAML file. Let’ call it jenkins-values.yaml
. Refer to values.yaml
in the Helm Chart to figure out what can be overridden.
My overrides look like this.
Master :
ServiceType : ClusterIP
InstallPlugins :
- kubernetes:0.12
- workflow-aggregator:2.5
- workflow-job:2.15
- credentials-binding:1.13
- git:3.5.1
- pipeline-github-lib:1.0
- ghprb:1.39.0
- blueocean:1.1.7
- ldap:1.20
- matrix-auth:2.2
- slack:2.3
AdminPassword : admin
ScriptApproval :
- " method groovy.json.JsonSlurperClassic parseText java.lang.String"
- " method hudson.model.Actionable getActions"
- " method java.lang.Class isInstance java.lang.Object"
- " method jenkins.plugins.git.AbstractGitSCMSource$SCMRevisionImpl getHash"
- " method jenkins.scm.api.SCMRevisionAction getRevision"
- " method org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper getRawBuild"
- " new groovy.json.JsonSlurperClassic"
- " staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods toBoolean java.lang.Boolean"
You can use a shell script which looks like this to deploy your Helm Chart. Let’s call this deploy.sh
. Pass two commandline to override the default Release Name and the Namespace.
#!/bin/bash
# Deploys Jenkins
RELEASE_NAME = ${ 1 :- jenkins }
NAMESPACE = ${ 2 :- default }
helm install -n $RELEASE_NAME --namespace $NAMESPACE -f ./jenkins-values.yaml stable/jenkins
Verification
To verify your installation, you can create a Pipeline Projects and run the Pipeline Script below.
def label = "mypod-${UUID.randomUUID().toString()}"
podTemplate ( label: label , containers: [
containerTemplate ( name: 'maven' , image: 'maven:3.3.9-jdk-8-alpine' , ttyEnabled: true , command: 'cat' ),
containerTemplate ( name: 'golang' , image: 'golang:1.8.0' , ttyEnabled: true , command: 'cat' )
]) {
node ( label ) {
stage ( 'Get a Maven project' ) {
git 'https://github.com/jenkinsci/kubernetes-plugin.git'
container ( 'maven' ) {
sh 'pwd'
sh 'ls'
}
}
stage ( 'Get a Golang project' ) {
git url: 'https://github.com/hashicorp/terraform.git'
container ( 'golang' ) {
sh """
pwd
ls
"""
}
}
}
}
Photo Credits
unsplash-logo Kyle Ryan