Skip to content

Commit d0ff364

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 53e323c commit d0ff364

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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-role
24+
match:
25+
any:
26+
- resources:
27+
kinds:
28+
- Namespace
29+
selector:
30+
matchLabels:
31+
konflux-ci.dev/type: tenant
32+
generate:
33+
kind: Role
34+
apiVersion: rbac.authorization.k8s.io/v1
35+
name: snapshot-access
36+
namespace: '{{request.object.metadata.name}}'
37+
synchronize: true
38+
data:
39+
rules:
40+
- apiGroups: ["snapshot.mycompany.io"] # Replace with actual CRD group
41+
resources: ["snapshots"]
42+
verbs: ["get", "list", "watch", "patch"]
43+
- name: generate-snapshot-rolebinding
44+
match:
45+
any:
46+
- resources:
47+
kinds:
48+
- Namespace
49+
selector:
50+
matchLabels:
51+
konflux-ci.dev/type: tenant
52+
generate:
53+
kind: RoleBinding
54+
apiVersion: rbac.authorization.k8s.io/v1
55+
name: snapshot-access-binding
56+
namespace: '{{request.object.metadata.name}}'
57+
synchronize: true
58+
data:
59+
roleRef:
60+
kind: Role
61+
name: snapshot-access
62+
apiGroup: rbac.authorization.k8s.io
63+
subjects:
64+
- kind: ServiceAccount
65+
name: konflux-cron-sa
66+
namespace: '{{request.object.metadata.name}}'

0 commit comments

Comments
 (0)