Skip to content

Commit

Permalink
Crete a Quickstart to run a Tekton task with Kind
Browse files Browse the repository at this point in the history
Introductory guide for newcomers. The approach in this doc is to be
easier to follow by providing prescriptive instructions about the tools
to use. After installing the prerequisites, doing copy/paste of the code
samples should work.
  • Loading branch information
geriom committed Oct 4, 2021
1 parent 86267cb commit 5ecc4b9
Show file tree
Hide file tree
Showing 2 changed files with 155 additions and 1 deletion.
2 changes: 1 addition & 1 deletion content/en/docs/Getting Started/pipelines.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "Getting Started with Pipelines"
linkTitle: "Getting Started with Pipelines"
weight: 1
weight: 2
description: >
Prerequisites, Installation, and Basic Usage
---
Expand Down
154 changes: 154 additions & 0 deletions content/en/docs/Getting Started/quickstart-kind.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
---
title: "Quickstart: Running Tekton on Kind"
likTitle: "Quickstart: Running Tekton on Kind"
weight: 1
description: >
Set up and run your first Tekton task in 5 minutes with Kind
---

[Kind](https://kind.sigs.k8s.io/) is a tool for running Kubernetes locally using
Docker.

## Prerequisites

1. [Install Docker](https://docs.docker.com/get-docker/)
1. [Install kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installation)
1. [Install kubectl](https://kind.sigs.k8s.io/docs/user/quick-start/#installation)

## Create your Kubernetes cluster

Create a cluster named `tektoncd`:

```bash
kind create cluster --name tektoncd
```

The process takes a few seconds, you see the following output:

<pre>
Creating cluster "tektoncd" ...
✓ Ensuring node image (kindest/node:v1.21.1) 🖼
✓ Preparing nodes 📦
✓ Writing configuration 📜
✓ Starting control-plane 🕹️
✓ Installing CNI 🔌
✓ Installing StorageClass 💾
Set kubectl context to "kind-tektoncd"
You can now use your cluster with:

kubectl cluster-info --context kind-tektoncd

Have a nice day! 👋
</pre>

You can check that the cluster was successfully created with `kubectl`:

```bash
kubectl cluster-info --context kind-tektoncd
```

The output confirms that Kubernetes is running:

<pre>
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'.
</pre>

## Install Tekton Pipelines

1. To install the latest version of Tekton Pipelines, use `kubectl`:

```bash
kubectl apply --context kind-tektoncd --filename \
https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml
```

1. Monitor the installation:

```bash
kubectl get pods --context kind-tektoncd --namespace tekton-pipelines --watch
```

When all components show `Running` under the `STATUS` column the installation
is complete.

Hit *Ctrl + C* to stop monitoring.

## Create and run a basic Task

A **Task** defines a series of **steps** that run sequentially to perform some
build work. Every Task runs as a pod on your Kubernetes cluster, with each step
running in its own container.

1. To create a task, open your favorite editor and create a file named
`hello-world.yaml` with the following content:

```yaml
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: echo-hello-world
spec:
steps:
- name: echo
image: alpine
command:
- echo
args:
- "Hello World"
```
1. Apply the Task to your cluster:
```bash
kubectl apply --context kind-tektoncd --filename hello-world.yaml
```

1. To run this task, you must instantiate it using `TaskRun`. Create another
file named `hello-world-run.yaml` with the following content:

```yaml
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: echo-hello-world-task-run
spec:
taskRef:
name: echo-hello-world
```
1. Apply the TaskRun to your cluster to launch the task:
```bash
kubectl apply --context kind-tektoncd --filename hello-world-run.yaml
```

1. Verify that everything worked correctly:

```bash
kubectl --context kind-tektoncd get taskrun echo-hello-world-task-run
```

The output of this command shows the status of the task

<pre>
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME
echo-hello-world-task-run True Succeeded 22h 22h
</pre>

The value `True` under `SUCCEEDED` confirms that TaskRun completed with no errors.

## Cleanup

To delete the cluster that you created for this quickstart run:

```bash
kind delete cluster --name tektoncd
```

## Further reading

* [Tekton Pipelines](/docs/pipelines)

0 comments on commit 5ecc4b9

Please sign in to comment.