Deploy Jenkins on an ACK Serverless cluster via Helm to run builds on dynamically provisioned pods.
Prerequisites
-
An ACK Serverless cluster is created.
-
kubectl is connected to your cluster.
Considerations
You are responsible for maintaining Jenkins. Enterprise-level technical support is not provided.
Step 1: Deploy Jenkins
-
Add and update the Jenkins Helm repository.
helm repo add jenkins https://charts.jenkins.io helm repo updateExpected output:
Hang tight while we grab the latest from your chart repositories... ...Successfully got an update from the "jenkins" chart repository Update Complete. ⎈Happy Helming!⎈NoteThe Helm repository is hosted outside the Chinese mainland. Updates from clusters in the Chinese mainland may take longer.
-
Install Jenkins.
-
Create the
cicdnamespace.kubectl create ns cicd -
Create a shared NAS storage volume.
Without a persistent volume for the Jenkins home directory, configurations are lost on controller pod restart.
-
Deploy Jenkins to the
cicdnamespace.helm -n cicd install jenkins jenkins/jenkins \ --set persistence.existingClaim=pvc-nas \ --set controller.serviceType="LoadBalancer" \ --set controller.adminPassword="admin"-
persistence.existingClaim=pvc-nas: Required. The PVC name. This example uses pvc-nas in the
cicdnamespace. -
controller.serviceType="LoadBalancer": Optional. The default service type is ClusterIP.
-
controller.adminPassword="admin": Optional. If unset, a random password is generated. See Access Jenkins via LoadBalancer and get the default password.
See helm-charts for all deployment parameters.
-
-
Check the Jenkins pod status. Wait until the pod enters the Running state.
kubectl -n cicd get poExpected output:
NAME READY STATUS RESTARTS AGE jenkins-0 2/2 Running 0 3m3s
-
-
Open Jenkins in a browser and log on with your credentials.
Step 2: Create a pipeline task
This example creates a pipeline named first-pipeline. Jenkins provisions a dynamic slave pod for each build and releases it on completion. See the Jenkins documentation for configuration details.
-
Log on to Jenkins. In the left-side navigation pane, click New Item.
-
In Enter an item name, enter first-pipeline, select Pipeline, and click OK.
-
Click the Pipeline tab, select Hello World, and click Save.
-
In the left-side navigation pane, click Build Now.
-
In Build History, click a build number such as #1. Click Console Output.
Access Jenkins and get the default password
-
The Jenkins service uses ClusterIP by default. To expose it via a load balancer:
kubectl -n cicd patch svc jenkins -p '{"spec": {"type": "LoadBalancer"}}' -
If no password was set during deployment, retrieve the default password:
kubectl -n cicd exec -it svc/jenkins -c jenkins -- /bin/cat /run/secrets/additional/chart-admin-password && echo