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 2020-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 | Renders a set of standardised labels |
| 11 | */}} |
| 12 | {{- define "phylo.metadata_labels" -}} |
| 13 | {{- $application := index . 0 -}} |
| 14 | {{- $context := index . 1 -}} |
| 15 | release: {{ $context.Release.Name }} |
| 16 | app: {{ $application }} |
| 17 | {{- end -}} |
| 18 | |
| 19 | {{/* |
| 20 | Render the given template. |
| 21 | */}} |
| 22 | {{- define "phylo.template" -}} |
| 23 | {{- $name := index . 0 -}} |
| 24 | {{- $context := index . 1 -}} |
| 25 | {{- $last := base $context.Template.Name }} |
| 26 | {{- $wtf := $context.Template.Name | replace $last $name -}} |
| 27 | {{ include $wtf $context }} |
| 28 | {{- end -}} |
| 29 | |
| 30 | {{/* |
| 31 | Render ServiceAccount, Role, and RoleBinding required for kubernetes-entrypoint. |
| 32 | */}} |
| 33 | {{- define "phylo.service_account" -}} |
| 34 | {{- $context := index . 1 -}} |
| 35 | {{- $saName := index . 0 -}} |
| 36 | {{- $saNamespace := $context.Release.Namespace }} |
| 37 | --- |
| 38 | apiVersion: v1 |
| 39 | kind: ServiceAccount |
| 40 | metadata: |
| 41 | name: {{ $saName }} |
| 42 | namespace: {{ $saNamespace }} |
| 43 | labels: |
| 44 | {{ tuple $saName $context | include "phylo.metadata_labels" | indent 4 }} |
| 45 | --- |
Hyunsun Moon | dea0cb5 | 2021-02-19 16:53:22 -0800 | [diff] [blame] | 46 | apiVersion: rbac.authorization.k8s.io/v1 |
Jeremy Ronquillo | 223db00 | 2020-06-05 10:28:22 -0700 | [diff] [blame] | 47 | kind: RoleBinding |
| 48 | metadata: |
| 49 | name: {{ $saName }} |
| 50 | namespace: {{ $saNamespace }} |
| 51 | labels: |
| 52 | {{ tuple $saName $context | include "phylo.metadata_labels" | indent 4 }} |
| 53 | roleRef: |
| 54 | apiGroup: rbac.authorization.k8s.io |
| 55 | kind: Role |
| 56 | name: {{ $saName }} |
| 57 | subjects: |
| 58 | - kind: ServiceAccount |
| 59 | name: {{ $saName }} |
| 60 | namespace: {{ $saNamespace }} |
| 61 | --- |
Hyunsun Moon | dea0cb5 | 2021-02-19 16:53:22 -0800 | [diff] [blame] | 62 | apiVersion: rbac.authorization.k8s.io/v1 |
Jeremy Ronquillo | 223db00 | 2020-06-05 10:28:22 -0700 | [diff] [blame] | 63 | kind: Role |
| 64 | metadata: |
| 65 | name: {{ $saName }} |
| 66 | namespace: {{ $saNamespace }} |
| 67 | labels: |
| 68 | {{ tuple $saName $context | include "phylo.metadata_labels" | indent 4 }} |
| 69 | rules: |
| 70 | - apiGroups: |
| 71 | - "" |
| 72 | - extensions |
| 73 | - batch |
| 74 | - apps |
| 75 | verbs: |
| 76 | - get |
| 77 | - list |
| 78 | resources: |
| 79 | - statefulsets |
| 80 | - daemonsets |
| 81 | - jobs |
| 82 | - pods |
| 83 | - services |
| 84 | - endpoints |
| 85 | - configmaps |
| 86 | {{- end -}} |