Repository navigation
Expand file tree
/
Copy pathrole.yaml
More file actions
127 lines (127 loc) · 3.89 KB
/
Copy pathrole.yaml
File metadata and controls
127 lines (127 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
---
# Least-privilege RBAC for the github-config app's ServiceAccount.
#
# Deliberately NOT the stock app pattern (a RoleBinding to the built-in `edit`
# ClusterRole) and deliberately NOT aggregated into `edit`: GitHub managed
# resources let their holder manipulate the org's real repositories, so that
# authority must be confined to THIS app — never inherited by every tenant that
# has an `edit` binding. Instead, a dedicated namespaced Role grants the SA full
# verbs over the namespaced provider-upjet-github managed-resource API groups,
# and only within the github-config namespace. Because the managed resources are
# namespaced (Crossplane v2 `*.github.m.upbound.io`), a plain Role + RoleBinding
# suffices — no ClusterRole/ClusterRoleBinding, no cluster RBAC.
#
# Each managed-resource rule names its resources explicitly rather than `*`, so
# the Role grants exactly the kinds the ManagedResourceActivationPolicy turns
# into CRDs and nothing else. That parity is the invariant: extend BOTH this
# file and
# k8s/providers/hetzner/infrastructure/crossplane/managed-resource-activation-policy.yaml
# when a new GitHub MR kind comes under management.
# scripts/tests/test-github-config-role-activation-parity.sh fails the build
# naming the missing kind if the two ever disagree, so the omission surfaces in
# CI instead of as a runtime apply failure inside the tenant's Flux
# Kustomization.
#
# The .github artifact the SA applies also contains the namespaced ProviderConfig
# (github.m.upbound.io) and the GitHub App credential ExternalSecret
# (external-secrets.io), so the SA needs verbs on those two groups too — still
# confined to this namespace. Neither is a managed resource, so neither
# participates in the activation-policy parity check above.
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: github-config-managed-resources
namespace: github-config
labels:
app.kubernetes.io/managed-by: ksail
rules:
- apiGroups:
- repo.github.m.upbound.io
resources:
- repositories
- defaultbranches
- branchprotections
- repositoryrulesets
- issuelabels
- repositorycustomproperties
- environments
- environmentdeploymentpolicies
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
# Team resources are high-impact because they change real GitHub org
# authorization. RBAC alone cannot express which teams this SA may manage, so
# the restrict-github-team-management and
# restrict-github-team-external-identity Kyverno admission policies constrain
# the allowed team identities, reference style, and repository permissions on
# top of these verbs.
- apiGroups:
- team.github.m.upbound.io
resources:
- teams
- teammemberships
- teamrepositories
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
- apiGroups:
- actions.github.m.upbound.io
resources:
- repositorypermissions
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
- apiGroups:
- enterprise.github.m.upbound.io
resources:
- organizationrulesets
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
# The tenant applies the namespaced ProviderConfig that binds its managed
# resources to the GitHub App credential. ProviderConfigUsage is written by
# the provider controller, never by this ServiceAccount, so it stays out.
- apiGroups:
- github.m.upbound.io
resources:
- providerconfigs
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
- apiGroups:
- external-secrets.io
resources:
- externalsecrets
verbs:
- get
- list
- watch
- create
- update
- patch
- delete