blob: ca3e85333bb2d9cf2426a75af0d49f34719afc1c [file] [log] [blame]
Jeremy Ronquillo11851d32020-06-08 15:13:08 -07001{{- /*
Jeremy Ronquilloec2d3e42020-06-05 11:33:39 -07002# Copyright 2019-present Open Networking Foundation
Jeremy Ronquillo11851d32020-06-08 15:13:08 -07003
Jeremy Ronquillo6046ce32020-06-18 11:06:29 -07004# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
Jeremy Ronquillo11851d32020-06-08 15:13:08 -07005*/ -}}
6
7{{/*
8Renders a set of standardised labels
9*/}}
10{{- define "cdn-remote.metadata_labels" -}}
11{{- $application := index . 0 -}}
12{{- $context := index . 1 -}}
13release: {{ $context.Release.Name }}
14app: {{ $application }}
15{{- end -}}
16
17{{/*
18Render 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{{/*
29Get 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{{/*
38Render 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---
45apiVersion: v1
46kind: ServiceAccount
47metadata:
48 name: {{ $saName }}
49 namespace: {{ $saNamespace }}
50 labels:
51{{ tuple $saName $context | include "cdn-remote.metadata_labels" | indent 4 }}
52---
53apiVersion: rbac.authorization.k8s.io/v1beta1
54kind: RoleBinding
55metadata:
56 name: {{ $saName }}
57 namespace: {{ $saNamespace }}
58 labels:
59{{ tuple $saName $context | include "cdn-remote.metadata_labels" | indent 4 }}
60roleRef:
61 apiGroup: rbac.authorization.k8s.io
62 kind: Role
63 name: {{ $saName }}
64subjects:
65 - kind: ServiceAccount
66 name: {{ $saName }}
67 namespace: {{ $saNamespace }}
68---
69apiVersion: rbac.authorization.k8s.io/v1beta1
70kind: Role
71metadata:
72 name: {{ $saName }}
73 namespace: {{ $saNamespace }}
74 labels:
75{{ tuple $saName $context | include "cdn-remote.metadata_labels" | indent 4 }}
76rules:
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 Ronquillo6046ce32020-06-18 11:06:29 -070094{{- end -}}