From 5ecc4b989fe2b64e5a495feb07331b50f3a70bbf Mon Sep 17 00:00:00 2001 From: Geri Ochoa Date: Thu, 23 Sep 2021 16:14:39 -0400 Subject: [PATCH] Crete a Quickstart to run a Tekton task with Kind 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. --- content/en/docs/Getting Started/pipelines.md | 2 +- .../docs/Getting Started/quickstart-kind.md | 154 ++++++++++++++++++ 2 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 content/en/docs/Getting Started/quickstart-kind.md diff --git a/content/en/docs/Getting Started/pipelines.md b/content/en/docs/Getting Started/pipelines.md index f95c914a5..758b68d34 100644 --- a/content/en/docs/Getting Started/pipelines.md +++ b/content/en/docs/Getting Started/pipelines.md @@ -1,7 +1,7 @@ --- title: "Getting Started with Pipelines" linkTitle: "Getting Started with Pipelines" -weight: 1 +weight: 2 description: > Prerequisites, Installation, and Basic Usage --- diff --git a/content/en/docs/Getting Started/quickstart-kind.md b/content/en/docs/Getting Started/quickstart-kind.md new file mode 100644 index 000000000..d6762df3c --- /dev/null +++ b/content/en/docs/Getting Started/quickstart-kind.md @@ -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: + +
+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! 👋
+
+ +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: + +
+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 + +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 + +
+     NAME                               SUCCEEDED    REASON       STARTTIME   COMPLETIONTIME
+	 echo-hello-world-task-run          True         Succeeded    22h         22h
+     
+ + 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)