Woojoong Kim | fdaa773 | 2019-10-08 10:08:25 -0700 | [diff] [blame] | 1 | {{- /* |
| 2 | # Copyright 2018-present Open Networking Foundation |
| 3 | # Copyright 2018 Intel Corporation |
| 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 | {{/* |
| 19 | Renders a set of standardised labels |
| 20 | */}} |
| 21 | {{- define "accelleran-cu.metadata_labels" -}} |
| 22 | {{- $application := index . 0 -}} |
| 23 | {{- $context := index . 1 -}} |
| 24 | release: {{ $context.Release.Name }} |
| 25 | app: {{ $application }} |
| 26 | {{- end -}} |
| 27 | |
| 28 | {{/* |
| 29 | Render ServiceAccount, Role, and RoleBinding required for kubernetes-entrypoint. |
| 30 | */}} |
| 31 | {{- define "accelleran-cu.service_account" -}} |
| 32 | {{- $context := index . 1 -}} |
| 33 | {{- $saName := index . 0 -}} |
| 34 | {{- $saNamespace := $context.Release.Namespace }} |
| 35 | --- |
| 36 | apiVersion: v1 |
| 37 | kind: ServiceAccount |
| 38 | metadata: |
| 39 | name: {{ $saName }} |
| 40 | namespace: {{ $saNamespace }} |
| 41 | labels: |
| 42 | {{ tuple $saName $context | include "accelleran-cu.metadata_labels" | indent 4 }} |
| 43 | --- |
| 44 | apiVersion: rbac.authorization.k8s.io/v1beta1 |
| 45 | kind: RoleBinding |
| 46 | metadata: |
| 47 | name: {{ $saName }} |
| 48 | namespace: {{ $saNamespace }} |
| 49 | labels: |
| 50 | {{ tuple $saName $context | include "accelleran-cu.metadata_labels" | indent 4 }} |
| 51 | roleRef: |
| 52 | apiGroup: rbac.authorization.k8s.io |
| 53 | kind: Role |
| 54 | name: {{ $saName }} |
| 55 | subjects: |
| 56 | - kind: ServiceAccount |
| 57 | name: {{ $saName }} |
| 58 | namespace: {{ $saNamespace }} |
| 59 | --- |
| 60 | apiVersion: rbac.authorization.k8s.io/v1beta1 |
| 61 | kind: Role |
| 62 | metadata: |
| 63 | name: {{ $saName }} |
| 64 | namespace: {{ $saNamespace }} |
| 65 | labels: |
| 66 | {{ tuple $saName $context | include "accelleran-cu.metadata_labels" | indent 4 }} |
| 67 | {{- end -}} |