Skip to content

Commit 1b1cf87

Browse files
committed
Add SA to each namespace for running cron jobs
This PR supports adding a UI for https://konflux-ci.dev/docs/testing/integration/periodic-integration-tests/ In order for the UI to work an SA with correct permissions to mutate snapshots must exist in the namespace with a predictable name. Signed-off-by: Brian Cook <[email protected]>
1 parent 325e606 commit 1b1cf87

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
kind: ClusterRole
3+
apiVersion: rbac.authorization.k8s.io/v1
4+
metadata:
5+
name: konflux-cron-sa-actions
6+
labels:
7+
konflux-cluster-role: "true"
8+
rules:
9+
- verbs:
10+
- get
11+
- list
12+
- watch
13+
- patch
14+
apiGroups:
15+
- appstudio.redhat.com
16+
resources:
17+
- snapshots

components/konflux-rbac/base/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ kind: Kustomization
33
resources:
44
- appstudio-pipelines-runner.yaml
55
- konflux-integration-runner.yaml
6+
- konflux-cron-sa-actions.yaml
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
apiVersion: kyverno.io/v1
2+
kind: ClusterPolicy
3+
metadata:
4+
name: init-ns-cron-sa
5+
spec:
6+
generateExisting: true
7+
rules:
8+
- name: generate-serviceaccount
9+
match:
10+
any:
11+
- resources:
12+
kinds:
13+
- Namespace
14+
selector:
15+
matchLabels:
16+
konflux-ci.dev/type: tenant
17+
generate:
18+
kind: ServiceAccount
19+
apiVersion: v1
20+
name: konflux-cron-sa
21+
namespace: '{{request.object.metadata.name}}'
22+
synchronize: true
23+
- name: generate-snapshot-rolebinding
24+
match:
25+
any:
26+
- resources:
27+
kinds:
28+
- Namespace
29+
selector:
30+
matchLabels:
31+
konflux-ci.dev/type: tenant
32+
generate:
33+
kind: RoleBinding
34+
apiVersion: rbac.authorization.k8s.io/v1
35+
name: snapshot-access-binding
36+
namespace: '{{request.object.metadata.name}}'
37+
synchronize: true
38+
data:
39+
roleRef:
40+
kind: ClusterRole
41+
name: konflux-cron-sa-actions
42+
apiGroup: rbac.authorization.k8s.io
43+
subjects:
44+
- kind: ServiceAccount
45+
name: konflux-cron-sa
46+
namespace: '{{request.object.metadata.name}}'

0 commit comments

Comments
 (0)