Skip to content

Commit c0103ae

Browse files
committed
Document how to use the kind tool and the Tekton/plumbing convenience script
1 parent c8dc797 commit c0103ae

File tree

1 file changed

+71
-14
lines changed

1 file changed

+71
-14
lines changed

DEVELOPMENT.md

+71-14
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ First, you may want to [Ramp up](#ramp-up) on Kubernetes and Custom Resource Def
1717
1. [Developing and testing](#developing-and-testing) Tekton pipelines
1818
1. Learn how to [iterate](#iterating) on code changes
1919
1. [Managing Tekton Objects using `ko`](#managing-tekton-objects-using-ko) in Kubernetes
20+
1. [Standing up a K8s cluster with Tekton using the kind tool](#standing-up-a-k8s-cluster-with-tekton-using-the-kind-tool)
2021
1. [Accessing logs](#accessing-logs)
2122
1. [Adding new CRD types](#adding-new-crd-types)
2223

@@ -81,7 +82,7 @@ You must install these tools:
8182

8283
> :warning: The user interacting with your K8s cluster **must be a cluster admin** to create role bindings.
8384
84-
**Setting cluster admin role example**:
85+
**Google Cloud Platform (GCP) example**:
8586

8687
```shell
8788
# Using gcloud to get your current user
@@ -98,7 +99,7 @@ To [build, deploy and run your Tekton Objects with `ko`](#install-pipeline), you
9899

99100
1. `GOROOT`: Set `GOROOT` to the location of the Go installation you want `ko` to use for builds.
100101

101-
> **NOTE** You may need to set `GOROOT` if you installed Go tools to a a non-default location or have multiple Go versions installed.
102+
> **Note**: You may need to set `GOROOT` if you installed Go tools to a non-default location or have multiple Go versions installed.
102103

103104
If it is not set, `ko` infers the location by effectively using `go env GOROOT`.
104105

@@ -131,7 +132,7 @@ For example:
131132
export PATH="${PATH}:$HOME/go/bin"
132133
```
133134

134-
> **Note** It is recommended to add these environment variables to your shell's configuration files (e.g., `~/.bash_profile` or `~/.bashrc`).
135+
> **Note**: It is recommended to add these environment variables to your shell's configuration files (e.g., `~/.bash_profile` or `~/.bashrc`).
135136
136137
### Setup a fork
137138
@@ -145,7 +146,7 @@ The Tekton project requires that you develop (commit) code changes to branches t
145146
git clone git@github.com:${YOUR_GITHUB_USERNAME}/pipeline.git
146147
```
147148
148-
> **Note** Tekton uses [Go Modules](https://golang.org/doc/modules/gomod-ref) (i.e., `go mod`) for package management so you may clone the repository to a location of your choosing.
149+
> **Note**: Tekton uses [Go Modules](https://golang.org/doc/modules/gomod-ref) (i.e., `go mod`) for package management so you may clone the repository to a location of your choosing.
149150
150151
1. Configure `git` remote repositories
151152
@@ -286,12 +287,9 @@ The recommended minimum development configuration is:
286287
--cluster-version=1.18
287288
```
288289
289-
> **Note** The recommended [GCE machine type](https://cloud.google.com/compute/docs/machine-types) is `n1-standard-4`
290-
> **Note** that
291-
[the `--scopes` argument to `gcloud container cluster create`](https://cloud.google.com/sdk/gcloud/reference/container/clusters/create#--scopes)
292-
controls what GCP resources the cluster's default service account has access
293-
to; for example to give the default service account full access to your GCR
294-
registry, you can add `storage-full` to your `--scopes` arg. See [Authenticating to GCP](https://cloud.google.com/kubernetes-engine/docs/tutorials/authenticating-to-cloud-platform) for more details.
290+
> **Note**: The recommended [GCE machine type](https://cloud.google.com/compute/docs/machine-types) is `'n1-standard-4'`.
291+
292+
> **Note**: [The `'--scopes'` argument](https://cloud.google.com/sdk/gcloud/reference/container/clusters/create#--scopes) on the `'gcloud container cluster create'` command controls what GCP resources the cluster's default service account has access to; for example, to give the default service account full access to your GCR registry, you can add `'storage-full'` to the `--scopes` arg. See [Authenticating to GCP](https://cloud.google.com/kubernetes-engine/docs/tutorials/authenticating-to-cloud-platform) for more details.
295293

296294
1. Grant cluster-admin permissions to the current user:
297295

@@ -312,9 +310,9 @@ While iterating on code changes to the project, you may need to:
312310
1. [Manage Tekton objects](managing-tekton-objects-using-ko)
313311
1. [Verify installation](#verify-installation) and make sure there are no errors by [accessing the logs](#accessing-logs)
314312
1. Use various development scripts, as needed, in the ['hack' directory](https://github.com/tektoncd/pipeline/tree/main/hack), For example:
315-
- Update your (external) dependencies with: `./hack/update-deps.sh`.
316-
- Update your type definitions with: `./hack/update-codegen.sh`.
317-
- Update your OpenAPI specs with: `./hack/update-openapigen.sh`.
313+
- Update your (external) dependencies with: `./hack/update-deps.sh`
314+
- Update your type definitions with: `./hack/update-codegen.sh`
315+
- Update your OpenAPI specs with: `./hack/update-openapigen.sh`
318316
1. Update or [add new CRD types](#adding-new-types) as needed
319317
1. Update, [add and run tests](./test/README.md#tests)
320318

@@ -325,6 +323,8 @@ To make changes to these CRDs, you will probably interact with:
325323
- The clients are in [./pkg/client](./pkg/client) (these are generated by
326324
`./hack/update-codegen.sh`)
327325

326+
---
327+
328328
### Managing Tekton Objects using `ko`
329329

330330
The `ko` command is the preferred method to manage (i.e., create, modify or delete) Tekton Objects in Kubernetes from your local fork of the project. Some common operations include:
@@ -361,7 +361,7 @@ As you make changes to the code, you can redeploy your controller with:
361361
ko apply -f config/controller.yaml
362362
```
363363
364-
#### Install in custom namespace
364+
#### Installing into custom namespaces
365365
366366
When managing different development branches of code (with changed Tekton objects and controllers) in the same K8s instance, it may be helpful to install them into a custom (non-default) namespace. The ability to map a code branch to a corresponding namespace may make it easier to identify and manage the objects as a group as well as isolate log output.
367367
@@ -381,12 +381,69 @@ kubectl set env deployments --all SYSTEM_NAMESPACE=${TARGET_NAMESPACE} -n ${TARG
381381
```
382382
383383
This script will cause `ko` to:
384+
384385
- Change (resolve) all `namespace` values in K8s configuration files within the `config/` subdirectory to be updated to a name of your choosing.
385386
- Builds and push images with the new namespace to your container registry and
386387
- Update all Tekton Objects in K8s using these images
387388
388389
It will also update the default system namespace used for K8s `deployments` to the new value for all subsequent `kubectl` commands.
389390
391+
---
392+
393+
### Standing up a K8s cluster with Tekton using the `kind` tool
394+
395+
An alternative to standing up your own K8s cluster and installing Tekton using `ko` is by using the [kind](https://kind.sigs.k8s.io/) tool. It was designed to help create and run local Kubernetes clusters in Docker to assist in local development and testing.
396+
397+
The [Tekton "plumbing" project](https://github.com/tektoncd/plumbing) provides a convenience script, named ['tekton_in_kind.sh'](https://github.com/tektoncd/plumbing/blob/main/hack/tekton_in_kind.sh), that leverages `kind` to create a cluster and then deploy Tekton Pipeline, [Tekton Triggers](https://github.com/tektoncd/triggers) and [Tekton Dashboard](https://github.com/tektoncd/dashboard) components into it.
398+
399+
See Tekton Plumbing's [DEVELOPMENT.md](https://github.com/tektoncd/plumbing/blob/main/DEVELOPMENT.md) for more details on this and other helpful scripts and tools.
400+
401+
#### Installation and prerequisites
402+
403+
- Clone the [Tekton Plumbing](https://github.com/tektoncd/plumbing) repository which has the ['tekton_in_kind.sh'](https://github.com/tektoncd/plumbing/blob/main/hack/tekton_in_kind.sh) and other helpful scripts.
404+
- `kind`: Install using its ["quick start"](https://kind.sigs.k8s.io/docs/user/quick-start/) documentation.
405+
- `Docker`: `kind` also requires Docker to be installed and running locally. Use the [Get Docker](https://docs.docker.com/get-docker/) instructions.
406+
407+
#### Create a cluster with Tekton components
408+
409+
Change into the Tekton plumbing repository you cloned and invoke the script:
410+
411+
```shell
412+
cd plumbing
413+
./hack/tekton_in_kind.sh
414+
```
415+
416+
The script, after using `kind` to create the K8s cluster, uses `kubectl` to install the `latest` released versions of Tekton components. After successful completion, the script will have:
417+
418+
- Created a K8s cluster named `tekton`
419+
- Created a `cluster-context` for `kubectl` named `'kind-tekton'` and set it as the `current-context`
420+
- Deployed the latest Tekton Pipeline, Trigger and Dashboard components
421+
- Made Tekton Dashboard available at `http://localhost:9097`
422+
423+
After the Tekton components are installed using this script, you can than use the `ko` tool to build and apply your development changes to the cluster for testing.
424+
425+
##### Using a different cluster name and Tekton versions
426+
427+
You can also specify a different cluster name and released versions of components you want installed:
428+
429+
```shell
430+
# Script usage:
431+
tekton_in_kind.sh [-c cluster-name -p pipeline-version -t triggers-version -d dashboard-version]"
432+
```
433+
434+
#### Delete the cluster
435+
436+
If you wish to delete the cluster that the script created, use the following command:
437+
438+
```shell
439+
# Delete the cluster using the default name
440+
kind delete cluster --name tekton
441+
```
442+
443+
> **Note**: Be sure to set a `kubectl` context, as its unset as a side-effect of the delete (i.e., `kubectl config use-context`*`<context-name>`*).
444+
445+
---
446+
390447
### Accessing logs
391448
392449
To look at the controller logs, run:

0 commit comments

Comments
 (0)