Code Monkey home page Code Monkey logo

tekton-kaniko-docker-build's Introduction

Overview

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.

Task List

  • Clone Private Git Repository
  • Build Docker Image
  • Push Docker Image to Private Docker Registry
  • Update ArgoCD manifest with new image tag
  • Configure Tekton Triggers

Directory Structure

tekton 
  ├───pipeline
  ├───pipelineRun
  ├───secrets
  ├───serviceAccount
  ├───triggers
  └───tasks
      ├───list-source.yaml
      └───tasksupdate-manifest.yaml
.gitignore
Dockerfile
index.js
package.json
README.md

Branches

  • 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)

ArgoCD Manifest

You can find the ArgoCD manifest from the following GitHub Repo.

Install Tekton Tasks

tkn hub install task git-clone

tkn hub install task kaniko

Commands

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

GitHub Authentication

Genearte SSH Key

ssh-keygen -t rsa -b 4096 -C "[email protected]"

Encode SSH Key

cat ~/.ssh/tekton_rsa | base64 -w 0

Create Secret

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>

Create Service Account

apiVersion: v1
kind: ServiceAccount
metadata:
  name: git-service-account
secrets:
  - name: git-ssh-key ### Secret name

Add Public Key to GitHub

cat ~/.ssh/tekton_rsa.pub

Now go to GitHub -> Settings -> SSH and GPG keys -> New SSH Key and paste the public key.

DockerHub Authentication

Create Docker Registry Config

mkdir -p ~/.docker && echo '{"auths": {"https://index.docker.io/v1/": {"username": "", "password": "", "email": ""}}}' > ~/.docker/config.json

Create Base64 Encoded Docker Registry Secret

cat ~/.docker/config.json | base64 -w0

Create Docker Registry Secret

apiVersion: v1
kind: Secret
metadata:
  name: docker-credential
data:
  config.json: <base64 encoded docker config>

tekton-kaniko-docker-build's People

Contributors

dinushchathurya avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

dmi3mis

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.