Skip to content

Commit f6cc7e7

Browse files
author
edge-katanomi-app2[bot]
committed
📚 Sync docs from alaudadevops/tektoncd-operator on 515298d9e11daf0aafc74cb495f7fc8d983584f7
Source: feat: add manual approval gate (#763) Author: l-qing Ref: refs/heads/main Commit: 515298d9e11daf0aafc74cb495f7fc8d983584f7 This commit automatically syncs documentation changes from the source-docs repository. 🔗 View source commit: https://github.com/alaudadevops/tektoncd-operator/commit/515298d9e11daf0aafc74cb495f7fc8d983584f7 🤖 Synced on 2025-11-18 05:24:12 UTC
1 parent 9d80ea9 commit f6cc7e7

File tree

5 files changed

+497
-3
lines changed

5 files changed

+497
-3
lines changed

.github/SYNC_INFO.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Documentation Sync Information
22

3-
- **Last synced**: 2025-11-17 07:19:21 UTC
3+
- **Last synced**: 2025-11-18 05:24:12 UTC
44
- **Source repository**: alaudadevops/tektoncd-operator
5-
- **Source commit**: [b908cd738c107ea344fbee70e7cfc0f88df5c71a](https://github.com/alaudadevops/tektoncd-operator/commit/b908cd738c107ea344fbee70e7cfc0f88df5c71a)
5+
- **Source commit**: [515298d9e11daf0aafc74cb495f7fc8d983584f7](https://github.com/alaudadevops/tektoncd-operator/commit/515298d9e11daf0aafc74cb495f7fc8d983584f7)
66
- **Triggered by**: edge-katanomi-app2[bot]
7-
- **Workflow run**: [#95](https://github.com/alaudadevops/tektoncd-operator/actions/runs/19421571524)
7+
- **Workflow run**: [#96](https://github.com/alaudadevops/tektoncd-operator/actions/runs/19455181392)
88

99
## Files synced:
1010
- docs/
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
weight: 200
3+
---
4+
5+
# ApprovalTask [openshiftpipelines.org/v1alpha1]
6+
7+
8+
<K8sCrd name="approvaltasks.openshiftpipelines.org" />
9+
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
weight: 70
3+
i18n:
4+
title:
5+
en: Deploy Manual Approval Gate
6+
zh: 部署手动审批关卡
7+
title: Deploy Manual Approval Gate
8+
---
9+
10+
# Deploying `Manual Approval Gate`
11+
12+
## Feature Overview
13+
14+
`Manual Approval Gate` provides the cluster-scoped controller and webhooks that back `ApprovalTask` custom tasks. Administrators must create and maintain the `ManualApprovalGate` custom resource (CR) so that platform users can insert manual approvals in their pipelines. This guide explains how to deploy the `Manual Approval Gate` component in `tekton-pipelines`, customize runtime options, and uninstall it safely.
15+
16+
## Use Cases
17+
18+
- Enabling manual approvals for all teams in the cluster by provisioning a managed controller.
19+
- Tweaking controller deployments (for example, replica counts, resource limits, or ConfigMaps) through the Operator's `options` contract instead of editing manifests.
20+
- Cleaning up the feature when approval tasks are no longer required.
21+
22+
## Prerequisites
23+
24+
- `Alauda DevOps Pipelines` v4.5.0 or later with cluster-admin access.
25+
- `kubectl` configured against the target cluster.
26+
27+
## Steps
28+
29+
### 1. Create the `ManualApprovalGate` CR
30+
31+
Save the manifest as `manual-approval-gate.yaml` and apply it:
32+
33+
```yaml
34+
apiVersion: operator.tekton.dev/v1alpha1
35+
kind: ManualApprovalGate
36+
metadata:
37+
name: manual-approval-gate
38+
spec:
39+
targetNamespace: tekton-pipelines
40+
options:
41+
disabled: false
42+
```
43+
44+
```bash
45+
kubectl apply -f manual-approval-gate.yaml
46+
```
47+
48+
- `spec.targetNamespace` determines where controller deployments, webhooks, and ConfigMaps are created. We recommend `tekton-pipelines` so that the component stays beside other Tekton services, but you can point it to any namespace as long as that namespace exists (or is created) before applying the CR.
49+
- Use `spec.options` to override Deployments, ConfigMaps, or image fields without editing generated YAML. For detailed syntax, refer to [Adjusting Optional Configuration Items of Subcomponents](../configure/customize_options.mdx).
50+
51+
### 2. Verify controller health
52+
53+
```bash
54+
$ kubectl get manualapprovalgates.operator.tekton.dev manual-approval-gate
55+
56+
NAME VERSION READY REASON
57+
manual-approval-gate v0.7.0-4f10729 True
58+
```
59+
60+
```bash
61+
$ kubectl get deployment -n tekton-pipelines | grep manual-approval-gate
62+
63+
manual-approval-gate-controller 1/1 1 1 1h1m
64+
manual-approval-gate-webhook 1/1 1 1 1h1m
65+
```
66+
67+
The CR's `READY` condition must report `True`, and you should see controller and webhook Deployments running in `tekton-pipelines`.
68+
69+
### 3. Reconfigure or force a rollout
70+
71+
- Patch the CR to adjust replicas or other options; the Operator rolls the workloads automatically:
72+
73+
```bash
74+
kubectl patch manualapprovalgate manual-approval-gate \
75+
--type merge \
76+
--patch '{"spec":{"options":{"deployments":{"manual-approval-gate-controller":{"spec":{"replicas":2}}}}}}'
77+
```
78+
79+
80+
### 4. Uninstall `Manual Approval Gate`
81+
82+
```bash
83+
$ kubectl delete manualapprovalgate manual-approval-gate
84+
$ kubectl get deployment -n tekton-pipelines | grep manual-approval-gate
85+
```
86+
87+
The CRD remains installed so you can recreate the CR later, but Deployments, Services, and Webhooks should disappear.
88+
89+
## Operation Results
90+
91+
- `kubectl get manualapprovalgates` shows the instance with `READY=True`, `VERSION=<release>`, and `REASON` empty or `Installed`.
92+
- `kubectl get pods -n tekton-pipelines | grep manual-approval-gate` lists controller and webhook pods in `Running` state.
93+
- After deletion, no pods or services with the same label remain, and the Operator stops reconciling `ApprovalTask` resources until the CR is recreated.
94+
95+
## Troubleshooting
96+
97+
- **`ManualApprovalGate` CR stuck in `NotReady`:** Run `kubectl describe manualapprovalgate manual-approval-gate` to check events, then review Operator logs (`kubectl logs -n tekton-operator deploy/tekton-operator`). Mis-typed fields in `spec.options` or insufficient privileges are the most common root causes.
98+
- **Controller/webhook pods crash looping:** Describe the failing pods in `tekton-pipelines` to confirm whether TLS secrets or configuration maps are missing. Reapplying the CR usually recreates these resources automatically.
99+
- **`ApprovalTask` resources not created:** Ensure the `ManualApprovalGate` CR still exists with `READY=True`. If it was deleted or is failing, reinstall it before users rerun pipelines.
100+
101+
## Learn More
102+
103+
- [Manual Approval Gate usage for pipeline authors](../pipelines/how_to/manual_approval_gate.mdx)
104+
- [Tekton Operator documentation](../overview/architecture.mdx)
105+
- [ApprovalTask upstream repository](https://github.com/openshift-pipelines/manual-approval-gate)
Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
---
2+
weight: 30
3+
i18n:
4+
title:
5+
en: Manual Approval Gate
6+
zh: 手动审批关卡
7+
title: Manual Approval Gate
8+
---
9+
10+
# `Manual Approval Gate` for `Tekton Pipelines`
11+
12+
## Feature Overview
13+
14+
`Manual Approval Gate` lets pipeline authors pause a `PipelineRun` until designated approvers review and approve the operation. Behind the scenes, the Operator-provided controller creates an `ApprovalTask` resource for every approval step, tracks approver responses, and writes the result back to the originating `CustomRun`.
15+
16+
## Use Cases
17+
18+
- Enforcing human checkpoints before deploying to production or performing destructive maintenance.
19+
- Implementing multi-person approval policies by combining individuals and groups with `numberOfApprovalsRequired`.
20+
- Auditing who approved or rejected a change by querying `ApprovalTask` status fields or CLI output.
21+
22+
## Prerequisites
23+
24+
- A cluster administrator has deployed `Manual Approval Gate`. If not, refer to the [deployment guide](../../how_to/manual_approval_gate_operator.mdx).
25+
- You can create or edit `Pipeline`/`PipelineRun` objects in the target namespace.
26+
- Approvers can patch `approvaltasks.openshift-pipelines.org` resources (typically via `kubectl`) in the target namespace. Platforms such as `Alauda Container Platform` grant this capability by default; only customize RBAC if you have explicitly removed the built-in permissions.
27+
28+
## Steps
29+
30+
### 1. Declare the approval step in a pipeline
31+
32+
```yaml
33+
apiVersion: tekton.dev/v1
34+
kind: Pipeline
35+
metadata:
36+
name: deploy-with-approval
37+
spec:
38+
tasks:
39+
- name: build
40+
taskRef:
41+
name: build-bundle # Placeholder Task; replace with your build logic
42+
- name: wait-for-approval
43+
runAfter:
44+
- build
45+
taskRef:
46+
apiVersion: openshift-pipelines.org/v1alpha1
47+
kind: ApprovalTask
48+
params:
49+
- name: approvers
50+
value:
51+
- alice
52+
- group:release-managers
53+
- name: numberOfApprovalsRequired
54+
value: "1"
55+
- name: timeout
56+
value: "24h"
57+
- name: description
58+
value: "Approve promotion into production"
59+
- name: deploy
60+
runAfter:
61+
- wait-for-approval
62+
taskRef:
63+
name: deploy-prod # Placeholder Task; replace with your deployment logic
64+
```
65+
66+
When the pipeline reaches `wait-for-approval`, `Tekton` emits a `CustomRun`. The approval controller creates an `ApprovalTask` with your parameters and keeps the `PipelineRun` pending until quorum is met or a rejection occurs.
67+
68+
### 2. Monitor approval status
69+
70+
```bash
71+
$ kubectl get approvaltasks.openshift-pipelines.org
72+
73+
NAME AGE
74+
deploy-with-approval-run-wait-for-approval 4m16s
75+
```
76+
77+
```bash
78+
$ kubectl describe approvaltask deploy-with-approval-run-wait-for-approval
79+
Name: deploy-with-approval-run-wait-for-approval
80+
Status:
81+
Approvals Received: 1
82+
Approvals Required: 1
83+
Approvers:
84+
alice
85+
release-managers
86+
Approvers Response:
87+
Name: alice
88+
Response: approved
89+
Type: User
90+
Start Time: 2025-11-17T10:37:01Z
91+
State: approved
92+
Events: <none>
93+
```
94+
95+
Important status fields:
96+
97+
- `status.state`: overall gate state such as `pending`, `approved`, or `rejected`.
98+
- `status.approvalsRequired` / `status.approvalsReceived`: quorum tracking (the received count appears only after at least one approver responds).
99+
- `status.approversResponse`: per-user/group outcome plus messages, useful for auditing.
100+
101+
### 3. Approve or reject
102+
103+
```bash
104+
$ kubectl get approvaltask deploy-with-approval-run-wait-for-approval -o json | jq '.spec.approvers'
105+
106+
$ kubectl patch approvaltask deploy-with-approval-run-wait-for-approval \
107+
--type='json' \
108+
--as alice \
109+
-p='[
110+
{"op":"replace","path":"/spec/approvers/0/input","value":"approve"},
111+
{"op":"replace","path":"/spec/approvers/0/message","value":"QA complete"}
112+
]'
113+
114+
$ kubectl patch approvaltask deploy-with-approval-run-wait-for-approval \
115+
--type='json' \
116+
--as alice \
117+
-p='[
118+
{"op":"replace","path":"/spec/approvers/0/input","value":"reject"},
119+
{"op":"replace","path":"/spec/approvers/0/message","value":"Found regression"}
120+
]'
121+
122+
$ kubectl patch approvaltask deploy-with-approval-run-wait-for-approval \
123+
--type='json' \
124+
--as bob \
125+
--as-group release-managers \
126+
-p='[
127+
{"op":"replace","path":"/spec/approvers/1/input","value":"approve"},
128+
{"op":"replace","path":"/spec/approvers/1/message","value":"Group approval from release-managers"}
129+
]'
130+
```
131+
132+
The first command helps you determine the array index for your approver entry. The JSON patches then update only the matched entry's `input` and `message`, whether it represents a user (`alice` in the example) or a user impersonating a group (`bob` acting for `release-managers`). The controller sets the corresponding `CustomRun` and `PipelineRun` to `Succeeded` or `Failed` accordingly: approvals accumulate until `numberOfApprovalsRequired` is satisfied, while any rejection immediately fails that section of the pipeline.
133+
134+
> **Tip:** Use `--as <username>` (required) and optionally `--as-group <group>` when you need to approve as a specific identity. The validation webhook allows you to modify only the entry that matches that impersonated user, so you often impersonate a user while also attaching the relevant group. RBAC must grant you impersonation rights. For example, `kubectl patch ... --as release-robot --as-group release-managers` simulates a service account acting for the `release-managers` group.
135+
136+
### 4. Extend `PipelineRun` timeouts for long approvals
137+
138+
If an approval could take hours or days, configure both `PipelineRun.spec.timeouts.pipeline` and `PipelineRun.spec.timeouts.tasks` to exceed the approval window so the run does not terminate before approvers respond. A simple `PipelineRun` to exercise the approval gate looks like the following:
139+
140+
```yaml
141+
apiVersion: tekton.dev/v1
142+
kind: PipelineRun
143+
metadata:
144+
name: deploy-with-approval-run
145+
spec:
146+
pipelineRef:
147+
name: deploy-with-approval
148+
timeouts:
149+
pipeline: 72h
150+
tasks: 72h
151+
```
152+
153+
Ensure the approval task's `timeout` parameter is shorter than the pipeline timeout. Otherwise, the `PipelineRun` might expire first, leaving the approval unresolved.
154+
155+
## Operation Results
156+
157+
- `kubectl get approvaltasks -o yaml` shows each approval gate with `state` and quorum-related fields (the `approvalsReceived` column appears after someone responds).
158+
- `PipelineRun` status reflects the approval outcome: when approved, downstream tasks resume; when rejected, the run fails with the reason propagated from the `ApprovalTask`.
159+
- Dispatch logs or `kubectl get approvaltask -o yaml` output provide the approval history for auditing.
160+
161+
## Troubleshooting
162+
163+
- **Approval task never appears:** Confirm the administrator-installed `ManualApprovalGate` CR is `READY`. Without the controller, `CustomRun` objects remain pending.
164+
- **Approvers lack permissions:** Grant them `get`, `list`, `update`, and `patch` access to `approvaltasks.openshift-pipelines.org` in the relevant namespace.
165+
- **Pipeline ended before approval finished:** Set both `PipelineRun.spec.timeouts.pipeline` and `PipelineRun.spec.timeouts.tasks` to cover the expected approval window, and ensure the approval `timeout` is realistic. Otherwise the run may time out even if approvers have not responded.
166+
- **Stuck in pending even after approvals:** Check `status.approversResponse` for users who changed their vote or rejected. You may need to update the approver list and rerun the pipeline.
167+
168+
## User and group identifiers
169+
170+
`Manual Approval Gate` relies on your platform's identity provider to match approver names. Always use the canonical identifiers exposed by the provider rather than UI display names. For example, on `Alauda Container Platform`:
171+
172+
```bash
173+
$ kubectl get users.auth.alauda.io
174+
NAME TYPE USERNAME AGE
175+
21232f297a57a5a743894a0e4a801fc3 local admin 19d
176+
```
177+
178+
Use the `USERNAME` column (such as `admin`) when adding user approvers.
179+
180+
```bash
181+
$ kubectl get groups.auth.alauda.io
182+
NAME DISPLAYNAME CONNTYPE CONNID AGE
183+
g-v9mfs test-group local local 19d
184+
```
185+
186+
Use the `NAME` column (such as `g-v9mfs`) when referencing group approvers (for example, `group:g-v9mfs`). Other platforms expose similar resources—consult the identity service documentation for the exact field names.
187+
188+
## Learn More
189+
190+
- [Deploying `Manual Approval Gate` as an administrator](../../how_to/manual_approval_gate_operator.mdx)
191+
- [Manual Approval Gate upstream repository](https://github.com/openshift-pipelines/manual-approval-gate)

0 commit comments

Comments
 (0)