Jeremy Ronquillo | 11851d3 | 2020-06-08 15:13:08 -0700 | [diff] [blame] | 1 | {{- /* |
Jeremy Ronquillo | ec2d3e4 | 2020-06-05 11:33:39 -0700 | [diff] [blame] | 2 | # Copyright 2019-present Open Networking Foundation |
Jeremy Ronquillo | 11851d3 | 2020-06-08 15:13:08 -0700 | [diff] [blame] | 3 | |
Jeremy Ronquillo | 6046ce3 | 2020-06-18 11:06:29 -0700 | [diff] [blame] | 4 | # SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0 |
Jeremy Ronquillo | 11851d3 | 2020-06-08 15:13:08 -0700 | [diff] [blame] | 5 | */ -}} |
| 6 | |
| 7 | {{/* |
| 8 | Renders a set of standardised labels |
| 9 | */}} |
| 10 | {{- define "cdn-local.metadata_labels" -}} |
| 11 | {{- $application := index . 0 -}} |
| 12 | {{- $context := index . 1 -}} |
| 13 | release: {{ $context.Release.Name }} |
| 14 | app: {{ $application }} |
| 15 | {{- end -}} |
| 16 | |
| 17 | {{/* |
| 18 | Render the given template. |
| 19 | */}} |
| 20 | {{- define "cdn-local.template" -}} |
| 21 | {{- $name := index . 0 -}} |
| 22 | {{- $context := index . 1 -}} |
| 23 | {{- $last := base $context.Template.Name }} |
| 24 | {{- $wtf := $context.Template.Name | replace $last $name -}} |
| 25 | {{ include $wtf $context }} |
| 26 | {{- end -}} |
| 27 | |
| 28 | {{/* |
| 29 | Render ServiceAccount, Role, and RoleBinding required for kubernetes-entrypoint. |
| 30 | */}} |
| 31 | {{- define "cdn-local.service_account" -}} |
| 32 | {{- $saName := index . 0 -}} |
| 33 | {{- $context := index . 1 -}} |
| 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 "cdn-local.metadata_labels" | indent 4 }} |
| 43 | --- |
Hyunsun Moon | dea0cb5 | 2021-02-19 16:53:22 -0800 | [diff] [blame] | 44 | apiVersion: rbac.authorization.k8s.io/v1 |
Jeremy Ronquillo | 11851d3 | 2020-06-08 15:13:08 -0700 | [diff] [blame] | 45 | kind: RoleBinding |
| 46 | metadata: |
| 47 | name: {{ $saName }} |
| 48 | namespace: {{ $saNamespace }} |
| 49 | labels: |
| 50 | {{ tuple $saName $context | include "cdn-local.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 | --- |
Hyunsun Moon | dea0cb5 | 2021-02-19 16:53:22 -0800 | [diff] [blame] | 60 | apiVersion: rbac.authorization.k8s.io/v1 |
Jeremy Ronquillo | 11851d3 | 2020-06-08 15:13:08 -0700 | [diff] [blame] | 61 | kind: Role |
| 62 | metadata: |
| 63 | name: {{ $saName }} |
| 64 | namespace: {{ $saNamespace }} |
| 65 | labels: |
| 66 | {{ tuple $saName $context | include "cdn-local.metadata_labels" | indent 4 }} |
| 67 | rules: |
| 68 | - apiGroups: |
| 69 | - "" |
| 70 | - extensions |
| 71 | - batch |
| 72 | - apps |
| 73 | verbs: |
| 74 | - get |
| 75 | - list |
| 76 | - patch |
| 77 | resources: |
| 78 | - statefulsets |
| 79 | - daemonsets |
| 80 | - jobs |
| 81 | - pods |
| 82 | - services |
| 83 | - endpoints |
| 84 | - configmaps |
Jeremy Ronquillo | 6046ce3 | 2020-06-18 11:06:29 -0700 | [diff] [blame] | 85 | {{- end -}} |