The repo for Tekton pipeline yaml & Flux2 deploy yaml & test app example
- fluxcd-manifests: Applying flux needs these yaml templates(automation deploy & automation image update included )
- tekton-manifests: kaniko pipeline & 2 methods of monitoring git changes(cronjob for git pull, git webhook)
-
Install flux to cluster installation doc
Eg:
flux bootstrap github \ --owner=Xinyan272\ --repository=test-flux \ --branch=demo \ --path=./cluster-env/demo1 \ --personal \ --read-write-key \ --components-extra=image-reflector-controller,image-automation-controller
-
Deploy a remote application from Git
Git repo has in addition to source code and deploy yaml files, flux kustomization monitor these yaml files regularly and synchronize deploy.
synchronize manual:
flux reconcile kustomization flux-system --with-source
-
Image update automation
- imageRepository : The image repository that needs to be monitored (Eg: imageRepoUrl/xinyan/test)
- imagePolicy : The ImagePolicy type gives rules for selecting a “latest” image from a scanned ImageRepository. imagePolicy examples
- imageUpdateAutomation: An automation process that will update a git repository, based on image policiy objects in the same namespace.
Attention:
- The automatic image update mechanism needs to comment imagePolicy after 'image' of deploy yaml file, otherwise it cannot be updated. Eg:
- image: imageRepoUrl/xinyan/test # {"$imagepolicy": "namespace:imagePolicyName"}
- Every different image needs imageRepo & imagePolicy respective
Using kaniko task & pipeline to build image and push to remote image repository.
2 methods of synchronizing git
-
git pull -> cronjob
A timed job to periodically monitor whether git has changed, and trigger a new pipelineRun if there is a change, nothing do if not.
reference: win5do/tekton-cicd-demo
-
git webhook -> tekton trigger
The pipelineRun is triggered by git webhook. As soon as git is updated, a new pipelineRun will be created automatically.