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-remote.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-remote.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 | Get Domain name |
| 30 | */}} |
| 31 | {{- define "cdn-remote.get_domain" -}} |
| 32 | {{- $service := index . 0 -}} |
| 33 | {{- $context := index . 1 -}} |
| 34 | {{- printf "%s.%s.svc.%s" $service $context.Release.Namespace $context.Values.config.clusterDomain -}} |
| 35 | {{- end -}} |
| 36 | |
| 37 | {{/* |
| 38 | Render ServiceAccount, Role, and RoleBinding required for kubernetes-entrypoint. |
| 39 | */}} |
| 40 | {{- define "cdn-remote.service_account" -}} |
| 41 | {{- $saName := index . 0 -}} |
| 42 | {{- $context := index . 1 -}} |
| 43 | {{- $saNamespace := $context.Release.Namespace }} |
| 44 | --- |
| 45 | apiVersion: v1 |
| 46 | kind: ServiceAccount |
| 47 | metadata: |
| 48 | name: {{ $saName }} |
| 49 | namespace: {{ $saNamespace }} |
| 50 | labels: |
| 51 | {{ tuple $saName $context | include "cdn-remote.metadata_labels" | indent 4 }} |
| 52 | --- |
| 53 | apiVersion: rbac.authorization.k8s.io/v1beta1 |
| 54 | kind: RoleBinding |
| 55 | metadata: |
| 56 | name: {{ $saName }} |
| 57 | namespace: {{ $saNamespace }} |
| 58 | labels: |
| 59 | {{ tuple $saName $context | include "cdn-remote.metadata_labels" | indent 4 }} |
| 60 | roleRef: |
| 61 | apiGroup: rbac.authorization.k8s.io |
| 62 | kind: Role |
| 63 | name: {{ $saName }} |
| 64 | subjects: |
| 65 | - kind: ServiceAccount |
| 66 | name: {{ $saName }} |
| 67 | namespace: {{ $saNamespace }} |
| 68 | --- |
| 69 | apiVersion: rbac.authorization.k8s.io/v1beta1 |
| 70 | kind: Role |
| 71 | metadata: |
| 72 | name: {{ $saName }} |
| 73 | namespace: {{ $saNamespace }} |
| 74 | labels: |
| 75 | {{ tuple $saName $context | include "cdn-remote.metadata_labels" | indent 4 }} |
| 76 | rules: |
| 77 | - apiGroups: |
| 78 | - "" |
| 79 | - extensions |
| 80 | - batch |
| 81 | - apps |
| 82 | verbs: |
| 83 | - get |
| 84 | - list |
| 85 | - patch |
| 86 | resources: |
| 87 | - statefulsets |
| 88 | - daemonsets |
| 89 | - jobs |
| 90 | - pods |
| 91 | - services |
| 92 | - endpoints |
| 93 | - configmaps |
Jeremy Ronquillo | 6046ce3 | 2020-06-18 11:06:29 -0700 | [diff] [blame] | 94 | {{- end -}} |