This repo contains all the required scripts to clone source from Private Git repository, build Docker image using Kaniko, push built Docker image to DockerHub and update ArgoCD manifest in separate private Git repo with the new image tag.
- Clone Private Git Repository
- Build Docker Image
- Push Docker Image to Private Docker Registry
- Update ArgoCD manifest with new image tag
- Configure Tekton Triggers
tekton
├───pipeline
├───pipelineRun
├───secrets
├───serviceAccount
├───triggers
└───tasks
├───list-source.yaml
└───tasksupdate-manifest.yaml
.gitignore
Dockerfile
index.js
package.json
README.md
- master (Complete pipeline with triggers)
- clone-build-push (Basic Pipeline with Git Clone, Build and Push)
- argo-manifest-update (Update ArgoCD manifest with new image tag and write-back to manifest repo)
- setup-triggers (Configure Tekton Triggers to trigger pipeline on push to master - completed pipeline)
You can find the ArgoCD manifest from the following GitHub Repo.
tkn hub install task git-clone
tkn hub install task kaniko
For the creation of required files like tasks,pipeline,pipelinRun, triggers and etc you can use the kubectl create -f <file-name>
command.
Examples:
kubectl create -f tekton/tasks/list-source.yaml ### Custom task to list source files
kubectl create -f tekton/tasks/update-manifest.yaml ### Custom task to update ArgoCD manifest
kubectl create -f tekton/pipeline/pipeline.yaml ### Pipeline definition
kubectl create -f tekton/pipelineRun/pipelineRun.yaml ### PipelineRun definition
ssh-keygen -t rsa -b 4096 -C "tekton@tekton.dev"
cat ~/.ssh/tekton_rsa | base64 -w 0
apiVersion: v1
kind: Secret
metadata:
name: git-ssh-key
annotations:
tekton.dev/git-0: github.com
type: kubernetes.io/ssh-auth
data:
ssh-privatekey: <base64 encoded private key>
apiVersion: v1
kind: ServiceAccount
metadata:
name: git-service-account
secrets:
- name: git-ssh-key ### Secret name
cat ~/.ssh/tekton_rsa.pub
Now go to GitHub -> Settings -> SSH and GPG keys -> New SSH Key and paste the public key.
mkdir -p ~/.docker && echo '{"auths": {"https://index.docker.io/v1/": {"username": "", "password": "", "email": ""}}}' > ~/.docker/config.json
cat ~/.docker/config.json | base64 -w0
apiVersion: v1
kind: Secret
metadata:
name: docker-credential
data:
config.json: <base64 encoded docker config>