This section will introduce how to use KubeVela with existing CI/CD tools such as Jenkins and why.
With a simple integration effort, KubeVela as a universal application delivery control plane can then supercharge existing CI/CD tools with modern application deployment capabilities such as:
- hybrid/multi-cloud delivery;
- cross-environments promotion;
- service mesh based application rollout/rollback;
- handling deployment dependencies and topology (DAG);
- declare, provision and consume cloud resources alongside with your application;
- enjoy benefits of GitOps delivery without the need to introduce full GitOps transformation to your team;
- ... and much more.
The following guide will use Jenkins as an example to release a sample HTTP server application step by step. The application code can be found in this GitHub repo.
Before combining KubeVela and Jenkins, you need to ensure the following environments have already been set up.
- Deploy Jenkins service with Docker support, including related plugins and credentials which will be used to access image repository.
- A git repository with Webhook enabled. Ensure commits to the target branch will trigger the running of the Jenkins pipeline.
- Get Kubernetes for deployment. Install KubeVela and enable its apiserver. Ensure the KubeVela apiserver can be accessed from external environment.
Deploy Jenkins pipeline with the following Groovy script. You can change the git repository address, image address, apiserver address and other environment configurations on demand. Your git repository should contain the
app.yaml configuration file to tell how to build the target image and which component the application contains.
Push commits to the target branch in the git repository, which the Jenkins pipeline focuses on. The webhook of git repo will trigger the newly created Jenkins pipeline. This pipeline will automatically build container images and push it to the image repository. Then it will send POST request to KubeVela apiserver, which will deploy
app.yaml to Kubernetes cluster. An example of
app.yaml is shown below.
THe GIT_COMMIT identifier will be replaced by the current git commit id in Jenkins pipeline. You can check the deployment status in Kubernetes through
In the deployed application, we use the
rollout trait, which enables us to release 2 pods first for canary validation. After validation succeed, remove
batchPatition: 0 in application configuration in the
rollout trait. After that, a complete release will be fired. This mechanism greatly improves the security and stability of the releasing process. You can adjust the rollout strategy depending on your scenario.
Refer to the blog post for more details about deploying Jenkins + KubeVela and more comprehensive demo for application rolling update.