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