An opinionated CI/CD platform built on top of Kubernetes.
Introduction from Cloudbees:
Terraform is recommended going forward.
K8s cluster must be compatiable with jx
.
Prerequisites:
- Know how classic Jenkins pipeline works
- Know how to operate on Kubernetes
- Know how to run Docker container
- Know how to use Helm
All JX projects are deployed to Kubernetes using Docker and Helm.
Aerial View
Jenkin X: https://jenkins-x.io/
Traditional CI/CD pipeline like classic Jenkins they require heavy customization, and not cloud-native.
Jenkins X is opinionated and cloud-native CI/CD pipeline built on top of Kubernetes. Jenkins X uses Tekton
(a Kubernetes-native pipeline engine) to do the job.
Setup Jenkins X
Create a cluser with Terraform on GCP.
Steps please see my github repository: https://github.com/chengdol/jenkins-X-deployment
First install gcloud SDK and Terraform at local.
1 | ## init the environment, configuration and link to the target gcloud project |
Then create main.tf
file to provision jenkins X cluster on GCP, go to https://registry.terraform.io/
and search jx
.
1 |
Create First App on Jenkins X Pipeline
Key components:
- Applciation code source
- Docker file: All services store in docker image
- Helm chart: All docker images wrapped in helm packages
- Jenkins X file: Defines the build pipeline
1 | jx create quickstart |
JX commands recap:
1 | ## out of box workflow for many language projects |
Environment with GitOps
Introduce GitOps
:
Jenkins X adopts GitOps, where Git is the single-source-of-truth for our environment.
1 | ## list all available environment |
Pull Requests and ChatOps
Jenkins streamlines the pull request workflow.
Prow
: https://jenkins-x.io/docs/reference/components/prow/
- Kubernetes CI/CD system
- Orchestrates Jenkins X pipelines via GitHub events
- Automates interactions with pull requests Enables
- ChatOps driven development
- GitHub only, to be superseded by Lighthouse
Github webhook will call Prow
, the webhook is actuall a HTTP POST request that contains the event payload, then Prow
will execute pipeline. Conversely, Prow
can call Github API.
Introduce ChatOps
:
1 | jx create pullrequest |
Creating Custom QucikStart and Build Packs
Build Packs
: https://buildpacks.io/, the Jenkins X project template, powered by Draft, contains:
- Dockerfile
- Production and Preview Helm charts
- Jenkins X pipeline
Quick start workflow: jx create quickstart -> choose quick start projects -> generate Vanilla project -> detects Build packs -> modifies Jenkins X project
So bascially, we use quickstart to create a vanilla project skeleton, then Jenkins X-ify this project by build packs (generate languange specific Jenkins X template files). So jx import
existing project also use build packs to do the job.
1 | ## list repositories containing quickstarts |
Customize Jenkins X Pipeline
Jenkins X file definition has YAML file structure, make use of inheritance to reduce repetition.
1 | ## validate pipeline syntax |
Versioning and Releasing App
Jenkins X adopts Semantic versioning
, split into 3 components.
- Major: breaking changes
- Minor: non-breaking changes
- Patch: bug fixes
Patch number is auto-incremented, Major/Minor versions are set manually.
Custom Domain and TLS
nip.io
, the IP with it is not human readable and prevents TLS, insecure. 比如外界访问部署后的应用。 Jenkins X allows custom domains and HTTPS
External DNS:
- Makes Kubernetes resources discoverable on public DNS servers
- Automates creation of DNS records
Certificate Manager:
- Issues SSL certificates for our applications
- Leverages
Lets Encrypt
behind the scenes
First buy domain from Google Domains web site then use it in Google Cloud settings.