Sylvain Desbureaux | 6f4e8c0 | 2021-04-19 15:26:15 +0200 | [diff] [blame^] | 1 | {{/* |
| 2 | # Copyright © 2020 Orange |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | */}} |
| 16 | |
| 17 | {{- $dot := . -}} |
| 18 | {{- range $role_type := $dot.Values.roles }} |
| 19 | --- |
| 20 | apiVersion: rbac.authorization.k8s.io/v1 |
| 21 | kind: Role |
| 22 | metadata: |
| 23 | name: {{ printf "%s-%s" (include "common.release" $dot) $role_type }} |
| 24 | namespace: {{ include "common.namespace" $dot }} |
| 25 | rules: |
| 26 | {{- if eq $role_type "read" }} |
| 27 | - apiGroups: |
| 28 | - "" # "" indicates the core API group |
| 29 | - apps |
| 30 | - batch |
| 31 | - extensions |
| 32 | resources: |
| 33 | - pods |
| 34 | - deployments |
| 35 | - jobs |
| 36 | - jobs/status |
| 37 | - statefulsets |
| 38 | - replicasets |
| 39 | - replicasets/status |
| 40 | - daemonsets |
| 41 | verbs: |
| 42 | - get |
| 43 | - watch |
| 44 | - list |
| 45 | {{- else }} |
| 46 | {{- if eq $role_type "create" }} |
| 47 | - apiGroups: |
| 48 | - "" # "" indicates the core API group |
| 49 | - apps |
| 50 | - batch |
| 51 | - extensions |
| 52 | resources: |
| 53 | - pods |
| 54 | - deployments |
| 55 | - jobs |
| 56 | - jobs/status |
| 57 | - statefulsets |
| 58 | - replicasets |
| 59 | - replicasets/status |
| 60 | - daemonsets |
| 61 | - secrets |
| 62 | verbs: |
| 63 | - get |
| 64 | - watch |
| 65 | - list |
| 66 | - apiGroups: |
| 67 | - "" # "" indicates the core API group |
| 68 | - apps |
| 69 | resources: |
| 70 | - statefulsets |
| 71 | verbs: |
| 72 | - patch |
| 73 | - apiGroups: |
| 74 | - "" # "" indicates the core API group |
| 75 | - apps |
| 76 | resources: |
| 77 | - deployments |
| 78 | - secrets |
| 79 | verbs: |
| 80 | - create |
| 81 | - apiGroups: |
| 82 | - "" # "" indicates the core API group |
| 83 | - apps |
| 84 | resources: |
| 85 | - pods |
| 86 | - persistentvolumeclaims |
| 87 | - secrets |
| 88 | - deployment |
| 89 | verbs: |
| 90 | - delete |
| 91 | - apiGroups: |
| 92 | - "" # "" indicates the core API group |
| 93 | - apps |
| 94 | resources: |
| 95 | - pods/exec |
| 96 | verbs: |
| 97 | - create |
| 98 | {{- else }} |
| 99 | # if you don't match read or create, then you're not allowed to use API |
| 100 | # except to see basic information about yourself |
| 101 | - apiGroups: |
| 102 | - authorization.k8s.io |
| 103 | resources: |
| 104 | - selfsubjectaccessreviews |
| 105 | - selfsubjectrulesreviews |
| 106 | verbs: |
| 107 | - create |
| 108 | {{- end }} |
| 109 | {{- end }} |
| 110 | {{- end }} |