Merge "[AAI] Add model-loader tracing config"
[oom.git] / kubernetes / common / serviceAccount / templates / role.yaml
1 {{/*
2 # Copyright © 2020 Orange
3 # Modifications Copyright © 2023 Deutsche Telekom AG
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #       http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 */}}
17
18 {{- $dot := . -}}
19 {{- range $role_type := $dot.Values.roles }}
20 {{/* Default roles are already created, just creating specific ones */}}
21 {{-   if not (has $role_type $dot.Values.defaultRoles) }}
22 ---
23 apiVersion: rbac.authorization.k8s.io/v1
24 kind: Role
25 metadata:
26   name: {{ include "common.fullname" (dict "suffix" $role_type "dot" $dot ) }}
27   namespace: {{ include "common.namespace" $dot }}
28 rules:
29 {{-     if hasKey $dot.Values.new_roles_definitions $role_type  }}
30 {{ include "common.tplValue" ( dict "value" (index $dot.Values.new_roles_definitions $role_type ) "context" $dot) }}
31 {{-     else}}
32 # if no rules are provided, you're back to 'nothing' role
33 - apiGroups:
34   - authorization.k8s.io
35   resources:
36   - selfsubjectaccessreviews
37   - selfsubjectrulesreviews
38   verbs:
39   - create
40 {{-     end }}
41 {{-   else if or ($dot.Values.global.createDefaultRoles) ($dot.Values.createDefaultRoles) }}
42 ---
43 apiVersion: rbac.authorization.k8s.io/v1
44 kind: Role
45 metadata:
46   name: {{ include "common.fullname" (dict "suffix" $role_type "dot" $dot ) }}
47   namespace: {{ include "common.namespace" $dot }}
48 rules:
49 {{-     if eq $role_type "read" }}
50 - apiGroups:
51   - "" # "" indicates the core API group
52   - apps
53   - batch
54   - extensions
55   resources:
56   - endpoints
57   - services
58   - nodes
59   - pods
60   - deployments
61   - deployments/status
62   - jobs
63   - jobs/status
64   - statefulsets
65   - replicasets
66   - replicasets/status
67   - daemonsets
68   verbs:
69   - get
70   - watch
71   - list
72 {{-     else  }}
73 {{-       if eq $role_type "create" }}
74 - apiGroups:
75   - "" # "" indicates the core API group
76   - apps
77   - batch
78   - extensions
79   resources:
80   - pods
81   - deployments
82   - deployments/status
83   - jobs
84   - jobs/status
85   - statefulsets
86   - replicasets
87   - replicasets/status
88   - daemonsets
89   - secrets
90   - services
91   verbs:
92   - get
93   - watch
94   - list
95 - apiGroups:
96   - "" # "" indicates the core API group
97   - apps
98   resources:
99   - statefulsets
100   - configmaps
101   verbs:
102   - patch
103 - apiGroups:
104   - "" # "" indicates the core API group
105   - apps
106   resources:
107   - deployments
108   - secrets
109   - services
110   - pods
111   verbs:
112   - create
113 - apiGroups:
114   - "" # "" indicates the core API group
115   - apps
116   resources:
117   - pods
118   - persistentvolumeclaims
119   - secrets
120   - deployments
121   - services
122   verbs:
123   - delete
124 - apiGroups:
125   - "" # "" indicates the core API group
126   - apps
127   resources:
128   - pods/exec
129   verbs:
130   - create
131 - apiGroups:
132   - cert-manager.io
133   resources:
134   - certificates
135   verbs:
136   - create
137   - delete
138 {{-       else }}
139 # if you don't match read or create, then you're not allowed to use API
140 # except to see basic information about yourself
141 - apiGroups:
142   - authorization.k8s.io
143   resources:
144   - selfsubjectaccessreviews
145   - selfsubjectrulesreviews
146   verbs:
147   - create
148 {{-       end }}
149 {{-     end }}
150 {{-   end }}
151 {{- end }}