Skip to content

Instantly share code, notes, and snippets.

@carltonmason
Last active July 28, 2021 12:58
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carltonmason/72a494080887175245a8abb7d3dc14f7 to your computer and use it in GitHub Desktop.
Save carltonmason/72a494080887175245a8abb7d3dc14f7 to your computer and use it in GitHub Desktop.

My notes for using k3d to run clusters locally with Tekton

Updated for working with k3d 3.x

Prereqs:

Setup:

  • create a k3d cluster called k3d-tekton-explore or just the default cluster name, like this k3d cluster create k3d-tekton-explore
  • If not already started, start the cluster with k3d cluster start k3d-tekton-explore and can be stopped with k3d stop k3d-tekton-explore. You can see if a cluster is running with k3d cluster list.
  • get the kubeconfig with export KUBECONFIG=$(k3d kubeconfig merge k3d-tekton-explore --switch-context)
  • create a k8s namespace that will be used when applying your pipeline yaml, I use kc create namespace ckmason-demo
  • install Tekton with kubectl apply --filename https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml, I installed the v1beta1 version. These get installed into the tekton-pipelines kube namespace
  • can verify with kubectl get pods -n tekton-pipelines
  • install the Tekton dashboard with kubectl apply --filename https://github.com/tektoncd/dashboard/releases/download/v0.11.0/tekton-dashboard-release.yaml
  • Use port forwarding to be able to see the Dashboard webui with kubectl --namespace tekton-pipelines port-forward svc/tekton-dashboard 9097:9097& (notice the trailing & so it runs in the background) and then visit localhost:9097 in your browser. Make sure you are viewing the right namespace or all namespaces in the dashboard to see your PipeLineRuns and TaskRuns
  • You can also use the tkn cli to view PipeLineRuns and TaskRuns as well as logs
  • I created some bash aliases for tkn and have them saved in my ~/.tkn_aliases.sh file and they are sourced in my ~/.bash_profile.
# A set of alias for the Tekton cli, aka tkn https://github.com/tektoncd/cli#tekton-pipelines-cli
# Note that tkn needs to know the k8s namespace to use,
# thus it is a good idea to set it with:
# `kubectl config set-context --current --namespace=ckmason-demo`
alias prd='tkn pipelinerun describe'
alias prlgs='tkn pipelinerun logs'
alias prls='tkn pipelinerun ls'
alias prrm='tkn pipeline delete'
alias trd='tkn taskrun describe'
alias trlgs='tkn taskrun logs'
alias trls='tkn taskrun ls'
alias trrm='tkn taskrun delete'

Once the setup above is done, then you can finally can do something useful with a local cluster and Tekton.

Typically, this will mean creating various Tekton Pipeline and Task resources via yaml files and applying them with kubectl to your cluster and checking the results with the Tekton Dashboard or tkn cli.

@naviat
Copy link

naviat commented Jun 3, 2021

Hi. I cannot create Tekton namespace with pod relatively, it shows the error is cannot pull image from gcr.io

image

do you have any idea about this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment