Getting started with Tasks
This tutorial shows you how to
- Create a Kubernetes cluster with minikube.
- Install Tekton pipelines.
- Create a Task.
- Use
TaskRun
to instantiate and run the Task.
Prerequisites
-
Install minikube. You only have to complete the step 1, “Installation”.
Create a Kubernetes cluster
Create a cluster:
minikube start --kubernetes-version v1.30.2
The process takes a few seconds, you see an output similar to the following, depending on the minikube driver that you are using:
😄 minikube v1.34.0 on Darwin 15.1.1 (arm64)
✨ Automatically selected the docker driver
📌 Using Docker Desktop driver with root privileges
👍 Starting "minikube" primary control-plane node in "minikube" cluster
🚜 Pulling base image v0.0.45 ...
💾 Downloading Kubernetes v1.30.2 preload ...
> preloaded-images-k8s-v18-v1...: 319.86 MiB / 319.86 MiB 100.00% 25.70 M
> gcr.io/k8s-minikube/kicbase...: 441.45 MiB / 441.45 MiB 100.00% 19.30 M
🔥 Creating docker container (CPUs=2, Memory=4000MB) ...
🐳 Preparing Kubernetes v1.30.2 on Docker 27.2.0 ...
▪ Generating certificates and keys ...
▪ Booting up control plane ...
▪ Configuring RBAC rules ...
🔗 Configuring bridge CNI (Container Networking Interface) ...
🔎 Verifying Kubernetes components...
▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟 Enabled addons: storage-provisioner, default-storageclass
🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
You can check that the cluster was successfully created with kubectl
:
kubectl cluster-info
The output confirms that Kubernetes is running:
Kubernetes control plane is running at https://127.0.0.1:39509
CoreDNS is running at
https://127.0.0.1:39509/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
Install Tekton Pipelines
-
To install the latest version of Tekton Pipelines, use
kubectl
:kubectl apply --filename \ https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml
-
Monitor the installation:
kubectl get pods --namespace tekton-pipelines --watch
When both
tekton-pipelines-controller
andtekton-pipelines-webhook
show1/1
under theREADY
column, you are ready to continue. For example:NAME READY STATUS RESTARTS AGE tekton-pipelines-controller-6d989cc968-j57cs 0/1 Pending 0 3s tekton-pipelines-webhook-69744499d9-t58s5 0/1 ContainerCreating 0 3s tekton-pipelines-controller-6d989cc968-j57cs 0/1 ContainerCreating 0 3s tekton-pipelines-controller-6d989cc968-j57cs 0/1 Running 0 5s tekton-pipelines-webhook-69744499d9-t58s5 0/1 Running 0 6s tekton-pipelines-controller-6d989cc968-j57cs 1/1 Running 0 10s tekton-pipelines-webhook-69744499d9-t58s5 1/1 Running 0 20s
Hit Ctrl + C to stop monitoring.
Create and run a basic Task
A Task, represented in the API as an object of kind Task
, defines a
series of Steps that run sequentially to perform logic that the Task
requires. Every Task runs as a pod on the Kubernetes cluster, with each step
running in its own container.
-
To create a Task, open your favorite editor and create a file named
hello-world.yaml
with the following content:apiVersion: tekton.dev/v1beta1 kind: Task metadata: name: hello spec: steps: - name: echo image: alpine script: | #!/bin/sh echo "Hello World"
-
Apply the changes to your cluster:
kubectl apply --filename hello-world.yaml
The output confirms that the Task was created successfully:
task.tekton.dev/hello created
-
A
TaskRun
object instantiates and executes this Task. Create another file namedhello-world-run.yaml
with the following content:apiVersion: tekton.dev/v1beta1 kind: TaskRun metadata: name: hello-task-run spec: taskRef: name: hello
-
Apply the changes to your cluster to launch the Task:
kubectl apply --filename hello-world-run.yaml
-
Verify that everything worked correctly:
kubectl get taskrun hello-task-run
The output of this command shows the status of the Task:
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME hello-task-run True Succeeded 22h 22h
The value
True
underSUCCEEDED
confirms that TaskRun completed with no errors. -
Take a look at the logs:
kubectl logs --selector=tekton.dev/taskRun=hello-task-run
The output displays the message:
Hello World
Cleanup
To learn about Tekton Pipelines, skip this section and proceed to the next tutorial.
To delete the cluster that you created for this guide run:
minikube delete
The output confirms that the cluster was deleted:
🔥 Deleting "minikube" in docker ...
🔥 Deleting container "minikube" ...
🔥 Removing /home/user/.minikube/machines/minikube ...
💀 Removed all traces of the "minikube" cluster.
Further Reading:
We recommend that you complete Getting started with Pipelines.
For more complex examples see:
Feedback
Was this page helpful?