Skip to content

Commit 69bdcbb

Browse files
authored
ci: install Tekton and PAC in cluster by default (knative#2896)
* ci: install Tekton and PAC in cluster by default * add PAC and Tekton to hack script versions * fix tekton affinity workaround
1 parent ec66c1a commit 69bdcbb

File tree

13 files changed

+114
-164
lines changed

13 files changed

+114
-164
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,6 @@ jobs:
171171
echo "------------------ finished! attempt $attempt ------------------"
172172
- name: Setup testing images
173173
run: ./hack/setup-testing-images.sh
174-
- name: Deploy Tekton
175-
run: ./hack/install-tekton.sh
176174
- name: Deploy Test Git Server
177175
run: ./hack/install-git-server.sh
178176
- name: E2E On Cluster Test

.github/workflows/test-e2e-oncluster-runtime.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ jobs:
4242
echo "------------------ finished! attempt $attempt ------------------"
4343
- name: Setup testing images
4444
run: ./hack/setup-testing-images.sh
45-
- name: Deploy Tekton
46-
run: ./hack/install-tekton.sh
4745
- name: Deploy Test Git Server
4846
run: ./hack/install-git-server.sh
4947
- name: E2E On Cluster Test (Runtimes)

.github/workflows/test-e2e-oncluster.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ jobs:
4040
echo "------------------ finished! attempt $attempt ------------------"
4141
- name: Setup testing images
4242
run: ./hack/setup-testing-images.sh
43-
- name: Deploy Tekton
44-
run: ./hack/install-tekton.sh
4543
- name: Deploy Test Git Server
4644
run: ./hack/install-git-server.sh
4745
- name: E2E On Cluster Test

.github/workflows/test-integration.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ jobs:
5252
run: ./hack/registry.sh
5353
- name: Setup testing images
5454
run: ./hack/setup-testing-images.sh
55-
- name: Install Tekton
56-
run: ./hack/install-tekton.sh
57-
- name: Install Pipelines as Code
58-
run: ./hack/install-pac.sh
5955
- name: Install Gitlab
6056
run: ./hack/install-gitlab.sh
6157
- name: Patch Hosts

docs/building-functions/on_cluster_build.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
This guide describes how you can build a Function on Cluster with Tekton Pipelines. The on cluster build is enabled by fetching Function source code from a remote Git repository. Buildpacks or S2I builder strategy can be used to build the Function image.
44

55
## Prerequisite
6-
1. Install Tekton Pipelines on the cluster. Please refer to [Tekton Pipelines documentation](https://github.com/tektoncd/pipeline/blob/main/docs/install.md) or run the following command:
6+
1. Install Tekton Pipelines on the cluster.
7+
8+
**Note:** If you're using `./hack/allocate.sh` for development/testing, Tekton and PAC are automatically installed.
9+
10+
For production environments, please refer to [Tekton Pipelines documentation](https://github.com/tektoncd/pipeline/blob/main/docs/install.md) or run the following command:
711
```bash
812
kubectl apply -f https://storage.googleapis.com/tekton-releases/pipeline/previous/v0.49.0/release.yaml
913
```

hack/allocate.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ main() {
3737
echo "evt: Eventing and Namespace"
3838
echo "reg: Local Registry"
3939
echo "dpr: Dapr Runtime"
40+
echo "tkt: Tekton Pipelines"
4041
echo ""
4142

4243
( set -o pipefail; (serving && dns && networking) 2>&1 | sed -e 's/^/svr /')&
4344
( set -o pipefail; (eventing && namespace) 2>&1 | sed -e 's/^/evt /')&
4445
( set -o pipefail; registry 2>&1 | sed -e 's/^/reg /') &
4546
( set -o pipefail; dapr_runtime 2>&1 | sed -e 's/^/dpr /')&
47+
( set -o pipefail; (tekton && pac) 2>&1 | sed -e 's/^/tkt /')&
4648

4749
local job
4850
for job in $(jobs -p); do
@@ -368,6 +370,70 @@ EOF
368370
echo "${green}✅ Dapr Runtime${reset}"
369371
}
370372

373+
tekton() {
374+
echo "${blue}Installing Tekton ${tekton_version} ${reset}"
375+
376+
tekton_release="previous/${tekton_version}"
377+
namespace="${NAMESPACE:-default}"
378+
379+
$KUBECTL apply -f "https://storage.googleapis.com/tekton-releases/pipeline/${tekton_release}/release.yaml"
380+
sleep 10
381+
$KUBECTL wait pod --for=condition=Ready --timeout=180s -n tekton-pipelines -l "app=tekton-pipelines-controller"
382+
$KUBECTL wait pod --for=condition=Ready --timeout=180s -n tekton-pipelines -l "app=tekton-pipelines-webhook"
383+
sleep 10
384+
385+
$KUBECTL create clusterrolebinding "${namespace}:knative-serving-namespaced-admin" --clusterrole=knative-serving-namespaced-admin --serviceaccount="${namespace}:default"
386+
387+
# TEMPORARY WORKAROUND: Disable affinity assistant to prevent pod scheduling issues
388+
# This is a workaround for issues where affinity assistant pod names don't match
389+
# what's expected by task pods, causing them to fail scheduling.
390+
# Related issues:
391+
# - https://github.com/tektoncd/pipeline/issues/6740
392+
# - https://github.com/tektoncd/pipeline/issues/7503
393+
# TODO: Remove this workaround once the underlying Tekton issue is resolved
394+
echo "${blue}- Disabling affinity assistant (temporary workaround)${reset}"
395+
$KUBECTL patch configmap feature-flags -n tekton-pipelines \
396+
-p '{"data":{"disable-affinity-assistant":"true"}}' \
397+
--type=merge
398+
399+
echo "${green}✅ Tekton${reset}"
400+
}
401+
402+
pac() {
403+
echo "${blue}Installing PAC (Pipelines-as-Code) ${pac_version} ${reset}"
404+
405+
local -r pac_ctr_host="${PAC_CONTROLLER_HOSTNAME:-pac-ctr.127.0.0.1.sslip.io}"
406+
407+
# Install Pipelines as Code
408+
$KUBECTL apply -f "https://raw.githubusercontent.com/openshift-pipelines/pipelines-as-code/release-${pac_version}/release.k8s.yaml"
409+
sleep 5
410+
$KUBECTL wait pod --for=condition=Ready -l '!job-name' -n pipelines-as-code --timeout=5m
411+
412+
# Install ingress for the PaC controller. This is used by VCS Webhooks.
413+
$KUBECTL apply -f - << EOF
414+
apiVersion: networking.k8s.io/v1
415+
kind: Ingress
416+
metadata:
417+
name: pipelines-as-code
418+
namespace: pipelines-as-code
419+
spec:
420+
ingressClassName: contour-external
421+
rules:
422+
- host: ${pac_ctr_host}
423+
http:
424+
paths:
425+
- backend:
426+
service:
427+
name: pipelines-as-code-controller
428+
port:
429+
number: 8080
430+
pathType: Prefix
431+
path: /
432+
EOF
433+
echo "the Pipeline as Code controller is available at: http://${pac_ctr_host}"
434+
echo "${green}✅ PAC${reset}"
435+
}
436+
371437
next_steps() {
372438
echo -e ""
373439
echo -e "${blue}Next Steps${reset}"

hack/cmd/update-knative-components/main.go

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
// Package main implements a tool for automatically updating component
2+
// versions for use in the hack/* scripts.
3+
//
4+
// Files interacted with:
5+
// 1. The source-of-truth file at hack/component-versions.json
6+
// 2. Autogenerated script at hack/component-versions.sh
7+
//
8+
// Usage:
9+
//
10+
// Most of the time this file will be used in a workflow that will run
11+
// on scheduled basis checking if a new latest version of corresponding
12+
// components exists (check components in 'Versions' struct). Please note that
13+
// KindNode is NOT being updated programmatically at this time.
14+
// When new latest version is detected, the program will create a PR in
15+
// knative/func repository with the latest changes allowing the CI/CD workflows
16+
// to run automatically before using the latest in main branch.
17+
//
18+
// Alternative use: You can run this file from hack/ directory to locally
19+
// regenerate 2 files mentioned above (if you made some changes etc.) - you can
20+
// use the root Makefile for your convenience -- 'make regenerate-kn-components'
121
package main
222

323
import (
@@ -14,31 +34,6 @@ import (
1434
github "github.com/google/go-github/v68/github"
1535
)
1636

17-
// -------------------------------------------------------------------------- \\
18-
// ---------------------------- File description ---------------------------- \\
19-
//
20-
// #update-knative-components/main.go -- This file takes care of updating
21-
// knative components programatically.
22-
//
23-
// Files interacted with:
24-
// 1) The source-of-truth file and its content can be found at
25-
// root/hack/component-versions.json
26-
// 2) autogenerated script in root/hack/component-versions.sh (2 directories up)
27-
//
28-
// How to use this file:
29-
// Most of the time this file will be used in a workflow that will run
30-
// on scheduled basis checking if a new latest version of corresponding
31-
// components exists (check components in 'Versions' struct). Please note that
32-
// KindNode is NOT being updated programatically at this time.
33-
// When new latest version is detected, the program will create a PR in
34-
// knative/func repository with the latest changes allowing the CI/CD workflows
35-
// to run automatically before using the latest in main branch.
36-
// Alternative use: You can run this file from hack/ directory to locally
37-
// regenerate 2 files mentioned above (if you made some changes etc.) - you can
38-
// use the root Makefile for your convenience -- 'make regenerate-kn-components'
39-
//
40-
// -------------------------------------------------------------------------- \\
41-
4237
const (
4338
fileScript string = "component-versions.sh"
4439
fileJson string = "component-versions.json"
@@ -59,6 +54,8 @@ set_versions() {
5954
knative_serving_version="{{.Serving}}"
6055
knative_eventing_version="{{.Eventing}}"
6156
contour_version="{{.Contour}}"
57+
tekton_version="{{.Tekton}}"
58+
pac_version="{{.Pac}}"
6259
}
6360
`
6461
)
@@ -69,6 +66,8 @@ type Versions struct {
6966
Serving string
7067
Eventing string
7168
Contour string
69+
Tekton string
70+
Pac string
7271
}
7372

7473
func main() {
@@ -367,7 +366,7 @@ func prExists(ctx context.Context, c *github.Client, title string) (bool, error)
367366
// -------------------------------------------------------------------------- \\
368367
// -------------------------------------------------------------------------- \\
369368

370-
// This is used when running this file with 1st argument "generate".
369+
// This is used when running this file with 1st argument "local".
371370
// Regenerate written files (source (.json) & autogenerated .sh file)
372371
// Generally you wont use this, but in case you make local changes to the
373372
// files, you can simply regenerate them with this

hack/cmd/update-knative-components/main_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,18 @@ set_versions() {
2525
knative_serving_version="v1.2.3"
2626
knative_eventing_version="v1.4.5"
2727
contour_version="v1.4.6"
28+
tekton_version="v0.56.4"
29+
pac_version="v0.24.6"
2830
}
2931
`
3032

3133
const expectedJson string = `{
3234
"KindNode": "v1.30",
3335
"Serving": "v1.2.3",
3436
"Eventing": "v1.4.5",
35-
"Contour": "v1.4.6"
37+
"Contour": "v1.4.6",
38+
"Tekton": "v0.56.4",
39+
"Pac": "v0.24.6"
3640
}
3741
`
3842

@@ -44,7 +48,9 @@ func TestRead(t *testing.T) {
4448
"Serving": "v1.14",
4549
"Eventing": "v1.15",
4650
"Contour": "v1.61",
47-
"KindNode": "1.3456"
51+
"KindNode": "1.3456",
52+
"Tekton": "v0.50.0",
53+
"Pac": "v0.20.0"
4854
}
4955
`
5056
tmpJson := path.Join(dir, "json.json")
@@ -72,6 +78,8 @@ func TestWrite(t *testing.T) {
7278
Eventing: "v1.4.5",
7379
Contour: "v1.4.6",
7480
KindNode: "v1.30",
81+
Tekton: "v0.56.4",
82+
Pac: "v0.24.6",
7583
}
7684

7785
// write to script (generate it)

hack/component-versions.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
"KindNode": "v1.32.0@sha256:c48c62eac5da28cdadcf560d1d8616cfa6783b58f0d94cf63ad1bf49600cb027",
33
"Serving": "v1.18.1",
44
"Eventing": "v1.18.1",
5-
"Contour": "v1.18.0"
5+
"Contour": "v1.18.0",
6+
"Tekton": "v0.56.4",
7+
"Pac": "v0.24.6"
68
}

hack/component-versions.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ set_versions() {
1414
knative_serving_version="v1.18.1"
1515
knative_eventing_version="v1.18.1"
1616
contour_version="v1.18.0"
17+
tekton_version="v0.56.4"
18+
pac_version="v0.24.6"
1719
}

0 commit comments

Comments
 (0)