Skip to content

Instantly share code, notes, and snippets.

@miclip
Last active November 6, 2019 02:23
Show Gist options
  • Save miclip/efe6b7451f48b001a2c34aac9a9c0819 to your computer and use it in GitHub Desktop.
Save miclip/efe6b7451f48b001a2c34aac9a9c0819 to your computer and use it in GitHub Desktop.
Deploy Jenkins to PKS (vsphere) with Helm

Deploy Jenkins to PKS (vsphere) with helm

Create storage class on vsphere:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: fast
provisioner: kubernetes.io/vsphere-volume
parameters:
    diskformat: zeroedthick
    datastore: LUN01
kubectl create -f ./storage-class.yml

Make the fast storage class the default:

kubectl patch storageclass fast -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
kubectl get events

NOTE: If there's an error about missing folder this is a bug in PKS 1.5 https://community.pivotal.io/s/article/failed-to-get-the-folder-reference create folder manually in vsphere, probably a folder with a guid name in pks-vms folder

Deploy jenkins helm chart:

kubectl create namespace jenkins
helm install --namespace jenkins --name jenkins stable/jenkins

Get jenkins admin password:

printf $(kubectl get secret --namespace jenkins jenkins -o jsonpath="{.data.jenkins-admin-password}" | base64 --decode);echo

Delete helm deployment:

helm del --purge jenkins

Deploy in Offline Environment

  1. Manually pull, save, load docker containers listed in values.yaml to your private repository.
  2. Update values.yaml images to pull the image from your private repo.
  3. On start Jenkins will attempt to install several plugins, these should be commented out in the values.yaml
  installPlugins:
    - kubernetes:1.18.2
    - workflow-job:2.33
    - workflow-aggregator:2.6
    - credentials-binding:1.19
    - git:3.11.0
  1. This will cause an error with the /templates/config.yaml file in that it expects to find the version of the kubernetes plugin. Delete the if statement.

before:

{{- if semverCompare ">=1.20.2" (include "jenkins.kubernetes-version" . ) }}
          <directConnection>false</directConnection>
{{- end }}

after:

    <directConnection>false</directConnection>
  1. helm package the chart
  2. helm install...
  3. You'll have to download and manually install the plugins within the Jenkins UI, each dependency will have to be installed first :(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment