Skip to content

Commit 85ca62d

Browse files
authored
Updated the tekton documentation to use the new buildpack task (#837)
* Updated the tekton documentation to use the new buildpack task supporting the extension. #814 Signed-off-by: cmoulliard <[email protected]> * Add additional words to vale dictionary Signed-off-by: cmoulliard <[email protected]> * Extend the documentation to have a chapter covering extension. Add new pipeline parameters Signed-off-by: cmoulliard <[email protected]> * Review the scenario and tested it using ubi8 and jammy builder images Signed-off-by: cmoulliard <[email protected]> * Fix some vale vocabularies Signed-off-by: cmoulliard <[email protected]> * Remove the cache workspace as not used and documented part of task's documentation Signed-off-by: cmoulliard <[email protected]> * Switch the builder image to use: cnbs/sample-builder Signed-off-by: cmoulliard <[email protected]> --------- Signed-off-by: cmoulliard <[email protected]>
1 parent cffa864 commit 85ca62d

File tree

2 files changed

+118
-53
lines changed
  • .github/styles/config/vocabularies/Buildpacks
  • content/docs/for-platform-operators/how-to/integrate-ci

2 files changed

+118
-53
lines changed

.github/styles/config/vocabularies/Buildpacks/accept.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,10 @@ rebase
1010
Rebasing
1111
SBOM(?s)
1212
semver
13-
Syft
13+
Syft
14+
[Tt]ekton
15+
[Kk]ubernetes
16+
uid
17+
Minikube
18+
kubectl
19+
Quarkus

content/docs/for-platform-operators/how-to/integrate-ci/tekton.md

Lines changed: 111 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@ weight=6
99

1010
[Tekton][tekton] is an open-source CI/CD system running on k8s.
1111

12-
The CNB project has created two reference "tasks" for performing buildpacks builds,
13-
both of which use the [lifecycle][lifecycle] directly (i.e. they do not use `pack`).
12+
The CNB project has created a reference "task" for performing buildpacks builds with or without extensions (aka Dockerfile to be applied) top
13+
of the [lifecycle][lifecycle] tool (i.e. they do not use `pack`).
1414

15-
<!--more-->
15+
The [Buildpacks Phases Task][buildpacks-phases] calls the individual [lifecycle][lifecycle] binaries (prepare, analyze, detect, restore, build or extender, export), to run each phase in a separate container.
1616

17-
They are:
17+
The uid and gid as defined part of the builder image will be used to build the image.
1818

19-
1. [buildpacks][buildpacks-task] `task` &rarr; This task, which we recommend using, calls the `creator` binary of the
20-
[lifecycle][lifecycle] to construct, and optionally publish, a runnable image.
21-
2. [buildpacks-phases][buildpacks-phases] `task` &rarr; This task calls the individual [lifecycle][lifecycle] binaries, to run each phase in a separate container.
19+
The different parameters to customize the task are defined part of the task's documentation under the section `parameters`.
2220

2321
## Set Up
2422

@@ -32,28 +30,22 @@ Before we get started, make sure you've got the following installed:
3230

3331
### 1. Install Tekton and Tekton Dashboard
3432

35-
To start, set up `Tekton`, using the Tekton [documentation][tekton-setup].
33+
To start, set up a `Tekton` version `>= 1.0`, using the Tekton [documentation][tekton-setup].
3634

3735
We also recommend using the `Tekton dashboard`. To install it, follow the steps in the [dashboard docs][tekton-dashboard-setup], and
3836
start the dashboard server.
3937

40-
### 2. Install the Buildpacks Task
41-
42-
Install the latest version of the buildpacks task (currently `0.6`), by running:
43-
44-
```shell
45-
kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/master/task/buildpacks/0.6/buildpacks.yaml
46-
```
38+
> NOTE: If you run Tekton on a Kind or Minikube Kubernetes cluster, be sure to set the `coschedule` flag to `disabled` within the `feature-flags` ConfigMap.
4739
48-
### 3. Install git-clone Task
40+
### 2. Install the Buildpacks Task
4941

50-
For our `pipeline`, we will use the `git-clone` task to clone a repository. Install the latest version (currently `0.4`), by running:
42+
Install the latest version of the buildpacks task (currently `0.3`), by running:
5143

5244
```shell
53-
kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/master/task/git-clone/0.4/git-clone.yaml
45+
kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/refs/heads/main/task/buildpacks-phases/0.3/buildpacks-phases.yaml
5446
```
5547

56-
### 4. Define and Apply Tekton Pipeline Resources
48+
### 3. Define and Apply Tekton Pipeline Resources
5749

5850
In order to set up our pipeline, we will need to define a few things:
5951

@@ -63,9 +55,9 @@ In order to set up our pipeline, we will need to define a few things:
6355
- PersistentVolumeClaim &rarr; A `PersistentVolumeClaim` (a general Kubernetes concept, generally shortened to PVC) is
6456
a request for storage by a user.
6557

66-
#### 4.1 PVCs
58+
#### 4.1 Persistent Volume
6759

68-
Create a file `resources.yml` that defines a `PersistentVolumeClaim`:
60+
Create a file `resources.yml` that defines a `PersistentVolumeClaim` able to store the git cloned project and buildpacks files:
6961

7062
```yaml
7163
apiVersion: v1
@@ -83,12 +75,12 @@ spec:
8375
#### 4.2 Authorization
8476
8577
> NOTE: You don't need to use authorization if you are pushing to a local registry. However, if you are pushing to a
86-
> remote registry (e.g. `DockerHub`, `GCR`), you need to add authorization
78+
> remote registry (e.g. `DockerHub`, `GCR`, `quay.io), you need to add authorization
8779

8880
Create a `Secret` containing username and password that the build should use to authenticate to the container registry.
8981

9082
```shell
91-
kubectl create secret docker-registry docker-user-pass \
83+
kubectl create secret docker-registry registry-user-pass \
9284
--docker-username=<USERNAME> \
9385
--docker-password=<PASSWORD> \
9486
--docker-server=<LINK TO REGISTRY, e.g. https://index.docker.io/v1/ > \
@@ -103,57 +95,70 @@ kind: ServiceAccount
10395
metadata:
10496
name: buildpacks-service-account
10597
secrets:
106-
- name: docker-user-pass
98+
- name: registry-user-pass
10799
```
100+
> NOTE: This service account will be used by Tekton in order to mount the credentials as docker config file part of the pod running buildpacks
108101

109102
#### 4.3 Pipeline
110103

111104
Create a file `pipeline.yml` that defines the `Pipeline`, and relevant resources:
112105

113106
```yaml
114-
apiVersion: tekton.dev/v1beta1
107+
apiVersion: tekton.dev/v1
115108
kind: Pipeline
116109
metadata:
117110
name: buildpacks-test-pipeline
118111
spec:
119112
params:
113+
- name: git-url
114+
type: string
115+
description: URL of the project to git clone
116+
- name: source-subpath
117+
type: string
118+
description: The subpath within the git project
120119
- name: image
121120
type: string
122121
description: image URL to push
122+
- name: builder
123+
type: string
124+
description: builder image URL
125+
- name: env-vars
126+
type: array
127+
description: env vars to pass to the lifecycle binaries
123128
workspaces:
124129
- name: source-workspace # Directory where application source is located. (REQUIRED)
125-
- name: cache-workspace # Directory where cache is stored (OPTIONAL)
126130
tasks:
127131
- name: fetch-repository # This task fetches a repository from github, using the `git-clone` task you installed
128132
taskRef:
129-
name: git-clone
133+
resolver: http
134+
params:
135+
- name: url
136+
value: https://raw.githubusercontent.com/tektoncd/catalog/refs/heads/main/task/git-clone/0.9/git-clone.yaml
130137
workspaces:
131138
- name: output
132139
workspace: source-workspace
133140
params:
134141
- name: url
135-
value: https://github.com/buildpacks/samples
136-
- name: subdirectory
137-
value: ""
142+
value: "$(params.git-url)"
138143
- name: deleteExisting
139144
value: "true"
140-
- name: buildpacks # This task uses the `buildpacks` task to build the application
145+
- name: buildpacks # This task uses the `buildpacks phases` task to build the application
141146
taskRef:
142-
name: buildpacks
147+
name: buildpacks-phases
143148
runAfter:
144149
- fetch-repository
145150
workspaces:
146151
- name: source
147152
workspace: source-workspace
148-
- name: cache
149-
workspace: cache-workspace
150153
params:
151154
- name: APP_IMAGE
152155
value: "$(params.image)"
153156
- name: SOURCE_SUBPATH
154-
value: "apps/java-maven" # This is the path within the samples repo you want to build (OPTIONAL, default: "")
155-
- name: BUILDER_IMAGE
156-
value: paketobuildpacks/builder:base # This is the builder we want the task to use (REQUIRED)
157+
value: "$(params.source-subpath)"
158+
- name: CNB_BUILDER_IMAGE
159+
value: "$(params.builder)"
160+
- name: CNB_ENV_VARS
161+
value: "$(params.env-vars[*])"
157162
- name: display-results
158163
runAfter:
159164
- buildpacks
@@ -185,24 +190,30 @@ kubectl apply -f resources.yml -f sa.yml -f pipeline.yml
185190
Create a file `run.yml`, which defines the `PipelineRun`:
186191

187192
```yaml
188-
apiVersion: tekton.dev/v1beta1
193+
apiVersion: tekton.dev/v1
189194
kind: PipelineRun
190195
metadata:
191196
name: buildpacks-test-pipeline-run
192197
spec:
193-
serviceAccountName: buildpacks-service-account # Only needed if you set up authorization
198+
taskRunTemplate:
199+
serviceAccountName: buildpacks-service-account # Only needed if you set up authorization
194200
pipelineRef:
195201
name: buildpacks-test-pipeline
196202
workspaces:
197203
- name: source-workspace
198204
subPath: source
199205
persistentVolumeClaim:
200206
claimName: buildpacks-source-pvc
201-
- name: cache-workspace
202-
subPath: cache
203-
persistentVolumeClaim:
204-
claimName: buildpacks-source-pvc
205207
params:
208+
- # The url of the git project to clone (REQURED).
209+
name: git-url
210+
value: https://github.com/buildpacks/samples
211+
- # This is the path within the git project you want to build (OPTIONAL, default: "")
212+
name: source-subpath
213+
value: "apps/java-maven"
214+
- # This is the builder image we want the task to use (REQUIRED).
215+
name: builder
216+
value: cnbs/sample-builder:noble
206217
- name: image
207218
value: <REGISTRY/IMAGE NAME, eg gcr.io/test/image > # This defines the name of output image
208219
```
@@ -225,27 +236,73 @@ kubectl describe pipelinerun buildpacks-test-pipeline-run
225236

226237
or by using the Tekton Dashboard.
227238

228-
Once the application is successfully built, you can pull it and run it by running:
239+
Once the application is successfully built, you can pull and run it by running:
229240

230241
```shell
231-
docker pull some-output-image
242+
docker | podman pull <REGISTRY/IMAGE NAME>
243+
docker | podman run -it <REGISTRY/IMAGE NAME>
244+
```
245+
246+
### 7. Using extension
247+
248+
If your builder image supports the [extension][extension] mechanism able to customize the [build][extension-build] or the [run (aka execution)][extension-run], then you can replay this scenario by simply changing within the `PipelineRun` resource file the builder parameter
249+
250+
```yaml
251+
apiVersion: tekton.dev/v1
252+
kind: PipelineRun
253+
metadata:
254+
name: buildpacks-test-pipeline-run
255+
spec:
256+
taskRunTemplate:
257+
serviceAccountName: buildpacks-service-account
258+
pipelineRef:
259+
name: buildpacks-test-pipeline
260+
workspaces:
261+
- name: source-workspace
262+
subPath: source
263+
persistentVolumeClaim:
264+
claimName: buildpacks-source-pvc
265+
params:
266+
- name: image
267+
value: <REGISTRY/IMAGE NAME, eg gcr.io/test/image>
268+
- name: git-url
269+
value: https://github.com/quarkusio/quarkus-quickstarts
270+
- name: source-subpath
271+
value: "getting-started"
272+
- name: builder
273+
value: paketobuildpacks/builder-ubi8-base:0.1.30
274+
- name: env-vars
275+
value:
276+
- BP_JVM_VERSION=21
277+
```
278+
When the build process starts, then you should see, part of the extender step, if you build a Java runtime (Quarkus, Spring boot, etc) such log messages if the extension installs by example a different JDK
279+
```txt
280+
2025-06-27T11:32:25.067007701Z time="2025-06-27T11:32:25Z" level=info msg="Performing slow lookup of group ids for root"
281+
2025-06-27T11:32:25.067243910Z time="2025-06-27T11:32:25Z" level=info msg="Running: [/bin/sh -c echo ${build_id}]"
282+
2025-06-27T11:32:25.095150183Z 9e447871-e415-4018-a860-d5a66d925a57
283+
2025-06-27T11:32:25.096877516Z time="2025-06-27T11:32:25Z" level=info msg="Taking snapshot of full filesystem..."
284+
2025-06-27T11:32:25.280396774Z time="2025-06-27T11:32:25Z" level=info msg="Pushing layer oci:/kaniko/cache/layers/cached:a035cdb3949daa8f4e7b2c523ea0d73741c7c2d5b09981c261ebae99fd2f3233 to cache now"
285+
2025-06-27T11:32:25.280572023Z time="2025-06-27T11:32:25Z" level=info msg="RUN microdnf --setopt=install_weak_deps=0 --setopt=tsflags=nodocs install -y openssl-devel java-21-openjdk-devel nss_wrapper which && microdnf clean all"
286+
2025-06-27T11:32:25.280577315Z time="2025-06-27T11:32:25Z" level=info msg="Cmd: /bin/sh"
287+
2025-06-27T11:32:25.280578398Z time="2025-06-27T11:32:25Z" level=info msg="Args: [-c microdnf --setopt=install_weak_deps=0 --setopt=tsflags=nodocs install -y openssl-devel java-21-openjdk-devel nss_wrapper which && microdnf clean all]"
288+
...
232289
```
233290

234-
### 7. Cleanup (Optional)
291+
### 8. Cleanup (Optional)
235292

236293
To clean up, run:
237294

238295
```shell
239-
kubectl delete taskrun --all
240-
kubectl delete pvc --all
241-
kubectl delete pv --all
296+
kubectl delete -n default pipelinerun buildpacks-test-pipeline-run
297+
kubectl delete -n default pipeline buildpacks-test-pipeline
298+
kubectl delete -n default buildpacks-phases
299+
kubectl delete -n default pvc buildpacks-source-pvc
242300
```
243301

244302
## References
245303

246-
The Buildpacks tasks can be accessed at:
304+
The Buildpacks task can be accessed at:
247305

248-
- [Buildpacks Task Source][buildpacks-task]
249306
- [Buildpacks Phases Task Source][buildpacks-phases]
250307

251308
Some general resources for Tekton are:
@@ -262,6 +319,8 @@ Some general resources for Tekton are:
262319
[tekton-setup]: https://tekton.dev/docs/getting-started/
263320
[tekton-dashboard-setup]: https://tekton.dev/docs/dashboard/
264321
[tekton-concepts]: https://tekton.dev/docs/concepts/
265-
[git-clone-task]: https://github.com/tektoncd/catalog/tree/master/task/git-clone
266322
[kubectl-install]: https://kubernetes.io/docs/tasks/tools/install-kubectl/
267323
[tekton-auth]: https://tekton.dev/docs/pipelines/auth/
324+
[extension]: https://buildpacks.io/docs/for-buildpack-authors/tutorials/basic-extension/02_why-dockerfiles/
325+
[extension-build]: https://buildpacks.io/docs/for-buildpack-authors/tutorials/basic-extension/04_build-dockerfile/
326+
[extension-run]: https://buildpacks.io/docs/for-buildpack-authors/tutorials/basic-extension/06_run-dockerfile-extend/

0 commit comments

Comments
 (0)