blob: 1b686f521caadf2748aad2e90fc2954c0f571ad7 [file] [log] [blame]
Sylvain Desbureaux45348812020-05-19 17:46:54 +02001{{/*
2# Copyright © 2020 Orange
Andreas Geisslerd4f832d2023-07-27 19:07:08 +02003# Modifications Copyright © 2023 Deutsche Telekom AG
Sylvain Desbureaux45348812020-05-19 17:46:54 +02004#
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
Sylvain Desbureaux6f4e8c02021-04-19 15:26:15 +020018{{- $dot := . -}}
Sylvain Desbureaux45348812020-05-19 17:46:54 +020019{{- range $role_type := $dot.Values.roles }}
Sylvain Desbureaux6f4e8c02021-04-19 15:26:15 +020020{{/* Default roles are already created, just creating specific ones */}}
21{{- if not (has $role_type $dot.Values.defaultRoles) }}
Sylvain Desbureaux45348812020-05-19 17:46:54 +020022---
23apiVersion: rbac.authorization.k8s.io/v1
24kind: Role
25metadata:
Sylvain Desbureaux6f4e8c02021-04-19 15:26:15 +020026 name: {{ include "common.fullname" (dict "suffix" $role_type "dot" $dot ) }}
Sylvain Desbureaux45348812020-05-19 17:46:54 +020027 namespace: {{ include "common.namespace" $dot }}
28rules:
Sylvain Desbureaux45348812020-05-19 17:46:54 +020029{{- 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}}
Sylvain Desbureaux6f4e8c02021-04-19 15:26:15 +020032# 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
Sylvain Desbureaux45348812020-05-19 17:46:54 +020040{{- end }}
Andreas Geisslerd4f832d2023-07-27 19:07:08 +020041{{- else if or ($dot.Values.global.createDefaultRoles) ($dot.Values.createDefaultRoles) }}
42---
43apiVersion: rbac.authorization.k8s.io/v1
44kind: Role
45metadata:
46 name: {{ include "common.fullname" (dict "suffix" $role_type "dot" $dot ) }}
47 namespace: {{ include "common.namespace" $dot }}
48rules:
49{{- if eq $role_type "read" }}
50- apiGroups:
51 - "" # "" indicates the core API group
52 - apps
53 - batch
54 - extensions
55 resources:
56 - pods
57 - deployments
58 - deployments/status
59 - jobs
60 - jobs/status
61 - statefulsets
62 - replicasets
63 - replicasets/status
64 - daemonsets
65 verbs:
66 - get
67 - watch
68 - list
69{{- else }}
70{{- if eq $role_type "create" }}
71- apiGroups:
72 - "" # "" indicates the core API group
73 - apps
74 - batch
75 - extensions
76 resources:
77 - pods
78 - deployments
79 - deployments/status
80 - jobs
81 - jobs/status
82 - statefulsets
83 - replicasets
84 - replicasets/status
85 - daemonsets
86 - secrets
87 - services
88 verbs:
89 - get
90 - watch
91 - list
92- apiGroups:
93 - "" # "" indicates the core API group
94 - apps
95 resources:
96 - statefulsets
97 - configmaps
98 verbs:
99 - patch
100- apiGroups:
101 - "" # "" indicates the core API group
102 - apps
103 resources:
104 - deployments
105 - secrets
106 - services
107 - pods
108 verbs:
109 - create
110- apiGroups:
111 - "" # "" indicates the core API group
112 - apps
113 resources:
114 - pods
115 - persistentvolumeclaims
116 - secrets
117 - deployments
118 - services
119 verbs:
120 - delete
121- apiGroups:
122 - "" # "" indicates the core API group
123 - apps
124 resources:
125 - pods/exec
126 verbs:
127 - create
128- apiGroups:
129 - cert-manager.io
130 resources:
131 - certificates
132 verbs:
133 - create
134 - delete
135{{- else }}
136# if you don't match read or create, then you're not allowed to use API
137# except to see basic information about yourself
138- apiGroups:
139 - authorization.k8s.io
140 resources:
141 - selfsubjectaccessreviews
142 - selfsubjectrulesreviews
143 verbs:
144 - create
145{{- end }}
146{{- end }}
Sylvain Desbureaux45348812020-05-19 17:46:54 +0200147{{- end }}
148{{- end }}