Jenkins supports continuous integration and continuous delivery (CI/CD). Deploy Jenkins in an ACK cluster for high availability and lower O&M costs. This topic explains how to deploy Jenkins and walks through a simple example that demonstrates application build and deployment.
Prerequisites
Helm CLI is installed and connected to the cluster using kubectl. For detailed instructions, see Installing Helm and Connect to an ACK cluster using kubectl.
Usage notes
No technical support is provided for Jenkins. You must maintain it on your own.
The Helm chart and container images for Jenkins are hosted outside Chinese mainland, which may cause image pull failures. Use one of the following solutions:
Subscribe to overseas source images using Container Registry. For instructions, see Sync images by using artifact subscription.
Create a Global Accelerator (GA) instance to pull images directly using its global acceleration network. For details, see Accelerate cross-region ACK image pulls with GA.
Step 1: Deploy Jenkins
-
Add 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!⎈ -
Install Jenkins.
-
Create a namespace named
cicd.kubectl create ns cicd -
Deploy Jenkins to the
cicdnamespace.helm -n cicd install jenkins jenkins/jenkins \ --set persistence.storageClass="alicloud-disk-essd" \ --set persistence.size="20Gi" \ --set controller.serviceType="LoadBalancer" \ --set controller.admin.password="<YOUR_SECURE_PASSWORD>"-
persistence.storageClass: Required. The storage class for the persistent volume storing jenkins_home. Set to"alicloud-disk-available"to auto-select an available cloud disk type. -
persistence.size: Required. The cloud disk size. Minimum: 20 GiB. -
controller.serviceType: Optional. The service type. Default: ClusterIP. -
controller.admin.password: Optional. The admin password. If unset, Jenkins generates a random password.
See helm-charts for other parameters.
-
-
Check the Jenkins pod status and wait for it to enter the Running state.
kubectl -n cicd get poExpected output:
NAME READY STATUS RESTARTS AGE jenkins-0 2/2 Running 0 3m3s
-
-
View the external IP address of the service.
If the service type is LoadBalancer, use the external IP address to access the Jenkins dashboard.
kubectl get -n cicd serviceExpected output:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE jenkins LoadBalancer 192.168.***.*** 8.222.***.*** 8080:30949/TCP 2d17h jenkins-agent ClusterIP 192.168.***.* <none> 50000/TCP 2d17h
(Optional) Step 2: Create a pipeline
Create a sample pipeline named first-pipeline. Jenkins dynamically launches a slave pod for each build and releases it upon completion. See Jenkins documentation for configuration options.
-
Log on to Jenkins. In the left-side navigation pane, click New Item.
-
In the Enter an item name section, enter first-pipeline, select Pipeline, and click OK.
-
Click the Pipeline tab, select the Hello World template, and click Save.
-
In the left-side navigation pane, click Build Now.
-
In the left-side navigation pane, click Build History. Click 1# > Console Output to view build results.
FAQ
How to retrieve the default Jenkins password?
If you did not specify a password during deployment, retrieve the default password:
kubectl -n cicd exec -it svc/jenkins -c jenkins -- /bin/cat /run/secrets/additional/chart-admin-password && echo