Jeremy Ronquillo | 223db00 | 2020-06-05 10:28:22 -0700 | [diff] [blame] | 1 | {{- /* |
Jeremy Ronquillo | ec2d3e4 | 2020-06-05 11:33:39 -0700 | [diff] [blame^] | 2 | |
Jeremy Ronquillo | 223db00 | 2020-06-05 10:28:22 -0700 | [diff] [blame] | 3 | # Copyright 2019-present Open Networking Foundation |
| 4 | # |
Jeremy Ronquillo | ec2d3e4 | 2020-06-05 11:33:39 -0700 | [diff] [blame^] | 5 | # SPDX-License-Identifier: Apache-2.0 |
| 6 | # SPDX-License-Identifier: LicenseRef-ONF-Member-Only |
| 7 | |
Jeremy Ronquillo | 223db00 | 2020-06-05 10:28:22 -0700 | [diff] [blame] | 8 | */ -}} |
| 9 | |
| 10 | {{/* |
| 11 | Render a set of standardised label |
| 12 | */}} |
| 13 | {{- define "accelleran-cbrs-common.metadata_labels" -}} |
| 14 | {{- $application := index . 0 -}} |
| 15 | {{- $context := index . 1 -}} |
| 16 | release: {{ $context.Release.Name }} |
| 17 | app: {{ $application }} |
| 18 | {{- end -}} |
| 19 | |
| 20 | {{/* |
| 21 | Render ServiceAccount, Role, and RoleBinding required for kubernetes-entrypoint. |
| 22 | */}} |
| 23 | {{- define "accelleran-cbrs-common.service_account" -}} |
| 24 | {{- $context := index . 1 -}} |
| 25 | {{- $saName := index . 0 -}} |
| 26 | {{- $saNamespace := $context.Release.Namespace }} |
| 27 | --- |
| 28 | apiVersion: v1 |
| 29 | kind: ServiceAccount |
| 30 | metadata: |
| 31 | name: {{ $saName }} |
| 32 | namespace: {{ $saNamespace }} |
| 33 | labels: |
| 34 | {{ tuple $saName $context | include "accelleran-cbrs-common.metadata_labels" | indent 4 }} |
| 35 | --- |
| 36 | apiVersion: rbac.authorization.k8s.io/v1beta1 |
| 37 | kind: RoleBinding |
| 38 | metadata: |
| 39 | name: {{ $saName }} |
| 40 | namespace: {{ $saNamespace }} |
| 41 | labels: |
| 42 | {{ tuple $saName $context | include "accelleran-cbrs-common.metadata_labels" | indent 4 }} |
| 43 | roleRef: |
| 44 | apiGroup: rbac.authorization.k8s.io |
| 45 | kind: Role |
| 46 | name: {{ $saName }} |
| 47 | subjects: |
| 48 | - kind: ServiceAccount |
| 49 | name: {{ $saName }} |
| 50 | namespace: {{ $saNamespace }} |
| 51 | --- |
| 52 | apiVersion: rbac.authorization.k8s.io/v1beta1 |
| 53 | kind: Role |
| 54 | metadata: |
| 55 | name: {{ $saName }} |
| 56 | namespace: {{ $saNamespace }} |
| 57 | labels: |
| 58 | {{ tuple $saName $context | include "accelleran-cbrs-common.metadata_labels" | indent 4 }} |
| 59 | rules: |
| 60 | - apiGroups: |
| 61 | - "" |
| 62 | - extensions |
| 63 | - batch |
| 64 | - apps |
| 65 | verbs: |
| 66 | - get |
| 67 | - list |
| 68 | - patch |
| 69 | resources: |
| 70 | - statefulsets |
| 71 | - daemonsets |
| 72 | - jobs |
| 73 | - pods |
| 74 | - services |
| 75 | - endpoints |
| 76 | - configmaps |
| 77 | {{- end -}} |