Jack Moore

Email: jack(at)jmoore53.com
Project Updates

Tekton Pipelines

28 Feb 2022 » kubernetes, golang, programming, software

Pipelines are the way I deploy this blog and I use them for building docker images and pushing them to my custom registry.

Deploying Tekton in K8s

kubectl apply --filename https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml

# None of this tkn bullshit is needed...
sudo apt update;sudo apt install -y gnupg
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3EFE0E0A2F2F60AA
echo "deb http://ppa.launchpad.net/tektoncd/cli/ubuntu eoan main"|sudo tee /etc/apt/sources.list.d/tektoncd-ubuntu-cli.list
sudo apt update && sudo apt install -y tektoncd-cli

From the install I needed the git clone and kaniko for the repo clone and build:

kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/main/task/git-clone/0.9/git-clone.yaml
kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/main/task/kaniko/0.6/kaniko.yaml

This was the install. From here I was good to go on creating a pipeline.

Creating a Pipeline

apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
  name: clone-build-push
spec:
  description: |
    This pipeline clones a git repo, builds a Docker image with Kaniko and
    pushes it to a registry    
  params:
  - name: repo-url
    type: string
  - name: image-reference
    type: string
  - name: revision
    type: string
  workspaces:
  - name: shared-data
  tasks:
  - name: fetch-source
    taskRef:
      name: git-clone
    workspaces:
    - name: output
      workspace: shared-data
    params:
    - name: url
      value: $(params.repo-url)
    - name: revision
      value: $(params.revision)
  - name: build-push
    runAfter: ["fetch-source"]
    taskRef:
      name: kaniko
    workspaces:
    - name: source
      workspace: shared-data
    params:
    - name: IMAGE
      value: $(params.image-reference)

And now that my pipeline was created, I was able to create a PipelineRun to run the pipeline.

PipelineRun

This pipeline run was run against the blog to build the jmoore53.com:2022wip branch.

apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
  generateName: clone-build-push-run-
spec:
  pipelineRef:
    name: clone-build-push
  podTemplate:
    securityContext:
      fsGroup: 65532
  workspaces:
  - name: shared-data
    volumeClaimTemplate:
      spec:
        storageClassName: local-hostpath
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 1Gi
  params:
  - name: repo-url
    value: https://gitea.atom.jmoore53.com/jmoore53/jmoore53.com.git
  - name: revision
    value: 2022wip
  - name: image-reference
    value: registry.dev.local:5000/jmoore53.com:2022wip

TODO

  • Use SSH
© Jack Moore - This site was last built Fri 30 Aug 2024 12:31:24 PM EDT