Getting Started

Introduction

This guide will take you from an empty Kubernetes cluster to a functioning Tekton Pipelines installation and a PipelineRun executing with a Pipeline stored in a git repo.

Prerequisites

  • A computer with kubectl.
  • A Kubernetes cluster running at least Kubernetes 1.22. A kind cluster should work fine for following the guide on your local machine.
  • An image registry that you can push images to. If you’re using kind make sure your KO_DOCKER_REPO environment variable is set to kind.local.
  • A publicly available git repository where you can put a pipeline yaml file.

Step 1: Install Tekton Pipelines and the Resolvers

See the installation instructions for Tekton Pipeline, and the installation instructions for the built-in resolvers.

Step 2: Configure Pipelines to enable alpha features and resolvers

Tekton Pipelines currently has its integration with remote resolution behind the alpha feature gate, and enabling specific resolvers is controlled by feature flags as well:

# update the feature-flags configmap in the tekton-pipelines namespace
kubectl patch -n tekton-pipelines configmap feature-flags -p '{"data":{"enable-api-fields":"alpha","enable-git-resolver":"true"}}'

# update the resolvers-feature-flags configmap in the tekton-pipelines-resolvers namespace
kubectl patch -n tekton-pipelines-resolvers configmap resolvers-feature-flags -p '{"data":{"enable-git-resolver":"true"}}'

The feature flags for the built-in resolvers are:

  • The bundles resolver: enable-bundles-resolver
  • The git resolver: enable-git-resolver
  • The hub resolver: enable-hub-resolver
  • The cluster resolver: enable-cluster-resolver

Step 3: Try it out!

In order to test out your install you’ll need a Pipeline stored in a public git repository. First cd into a clone of your repo and then create a new branch:

# checkout a new branch in the public repo you're using
git checkout -b add-a-simple-pipeline

Then create a basic pipeline:

cat <<"EOF" > pipeline.yaml
kind: Pipeline
apiVersion: tekton.dev/v1beta1
metadata:
  name: a-simple-pipeline
spec:
  params:
  - name: username
  tasks:
  - name: task-1
    params:
    - name: username
      value: $(params.username)
    taskSpec:
      params:
      - name: username
      steps:
      - image: alpine:3.15
        script: |
          echo "hello $(params.username)"
EOF

Commit the pipeline and push it to your git repo:

git add ./pipeline.yaml
git commit -m "Add a basic pipeline to test Tekton Pipeline remote resolution"

# push to your publicly accessible repository, replacing origin with
# your git remote's name
git push origin add-a-simple-pipeline

And finally create a PipelineRun that uses your pipeline:

# first assign your public repo's url to an environment variable
REPO_URL=# insert your repo's url here

# create a pipelinerun yaml file
cat <<EOF > pipelinerun.yaml
kind: PipelineRun
apiVersion: tekton.dev/v1beta1
metadata:
  name: run-basic-pipeline-from-git
spec:
  pipelineRef:
    resolver: git
    params:
    - name: url
      value: ${REPO_URL}
    - name: branch
      value: add-a-simple-pipeline
    - name: path
      value: pipeline.yaml
  params:
  - name: username
    value: liza
EOF

# execute the pipelinerun
kubectl apply -f ./pipelinerun.yaml

Step 6: Monitor the PipelineRun

First let’s watch the PipelineRun to see if it succeeds:

kubectl get pipelineruns -w

Shortly the PipelineRun should move into a Succeeded state.

Now we can check the logs of the PipelineRun’s only task:

kubectl logs run-basic-pipeline-from-git-task-1-pod
# This should print "hello liza"

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License.