Deploy Jenkins on an ACK Serverless cluster and use a simple example to build and deploy an application.
Prerequisites
-
You have created an ACK Serverless cluster. For more information, see Create an ACK Serverless cluster.
-
You are connected to your Kubernetes cluster using kubectl. For more information, see Connect to a Kubernetes cluster by using kubectl.
Considerations
You are responsible for maintaining your Jenkins system. Enterprise-level technical support is not provided for Jenkins.
Step 1: Deploy Jenkins
-
Run the following commands to 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 located outside the Chinese mainland. If you update the repository from an ACK Serverless cluster in the Chinese mainland, the process might take longer.
-
Install Jenkins.
-
Run the following command to create the
cicdnamespace.kubectl create ns cicd -
Create a shared NAS storage volume.
Without a persistent volume for the Jenkins home directory, all configurations are lost if the controller pod restarts.
-
If you are using the Container Storage Interface (CSI) plug-in, see Use a statically provisioned NAS volume.
-
If you are using the FlexVolume plug-in, see Use a statically provisioned NAS volume.
-
-
Run the following command to 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 name of the persistent volume claim (PVC). In this example, the PVC is named pvc-nas and is created in the
cicdnamespace. -
controller.serviceType="LoadBalancer": Optional. The default service type is ClusterIP.
-
controller.adminPassword="admin": Optional. If you do not set this parameter, a random password is automatically generated. To obtain the password, see Access Jenkins and get the default password.
For more information about deployment parameters, see helm-charts.
-
-
Run the following command to check the status of the Jenkins pod. Wait for the pod to enter the Running state.
kubectl -n cicd get poExpected output:
NAME READY STATUS RESTARTS AGE jenkins-0 2/2 Running 0 3m3s
-
-
Access the Jenkins service in a web browser and log in with your username and password.
For more information, see Access Jenkins and get the default password.
Step 2: Create a pipeline task
Create a pipeline task named first-pipeline. When you run the pipeline, Jenkins automatically launches a dynamic slave pod in your ACK Serverless cluster to execute the build job. After the job completes, the slave pod is immediately released. For more information about Jenkins configurations, see the official Jenkins documentation.
-
Log in to Jenkins. In the left navigation pane, click New Item.
-
In the Enter an item name field, enter first-pipeline, select Pipeline as the item type, and then click OK.
-
Click the Pipeline tab, select the Hello World template, and then click Save.
-
In the left navigation pane, click Build Now to start the build.
-
In the Build History section of the left navigation pane, click a build number, such as #1, to open the build's details page. Then, click Console Output to view the build output.
Access Jenkins and get the default password
-
By default, the Jenkins service uses the ClusterIP type. To expose the service via a load balancer, run the following command:
kubectl -n cicd patch svc jenkins -p '{"spec": {"type": "LoadBalancer"}}' -
If you did not specify a password during deployment, run the following command to retrieve the default random password:
kubectl -n cicd exec -it svc/jenkins -c jenkins -- /bin/cat /run/secrets/additional/chart-admin-password && echo