blob: 69921bd8392dc3838885b831e1c63753135f7730 [file] [log] [blame]
Woojoong Kim3f51f0c2019-09-06 11:31:13 -07001{{- /*
2Copyright 2019-present Open Networking Foundation
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/ -}}
16
17{{/*
18Renders a set of standardised labels
19*/}}
20{{- define "cdn-remote.metadata_labels" -}}
21{{- $application := index . 0 -}}
22{{- $context := index . 1 -}}
23release: {{ $context.Release.Name }}
24app: {{ $application }}
25{{- end -}}
26
27{{/*
28Render the given template.
29*/}}
30{{- define "cdn-remote.template" -}}
31{{- $name := index . 0 -}}
32{{- $context := index . 1 -}}
33{{- $last := base $context.Template.Name }}
34{{- $wtf := $context.Template.Name | replace $last $name -}}
35{{ include $wtf $context }}
36{{- end -}}
37
38{{/*
39Get Domain name
40*/}}
41{{- define "cdn-remote.get_domain" -}}
42{{- $service := index . 0 -}}
43{{- $context := index . 1 -}}
Woojoong Kim7e100332020-02-03 11:17:39 -080044{{- printf "%s.%s.svc.%s" $service $context.Release.Namespace $context.Values.config.clusterDomain -}}
Woojoong Kim3f51f0c2019-09-06 11:31:13 -070045{{- end -}}
46
47{{/*
48Render ServiceAccount, Role, and RoleBinding required for kubernetes-entrypoint.
49*/}}
50{{- define "cdn-remote.service_account" -}}
51{{- $saName := index . 0 -}}
52{{- $context := index . 1 -}}
53{{- $saNamespace := $context.Release.Namespace }}
54---
55apiVersion: v1
56kind: ServiceAccount
57metadata:
58 name: {{ $saName }}
59 namespace: {{ $saNamespace }}
60 labels:
61{{ tuple $saName $context | include "cdn-remote.metadata_labels" | indent 4 }}
62---
63apiVersion: rbac.authorization.k8s.io/v1beta1
64kind: RoleBinding
65metadata:
66 name: {{ $saName }}
67 namespace: {{ $saNamespace }}
68 labels:
69{{ tuple $saName $context | include "cdn-remote.metadata_labels" | indent 4 }}
70roleRef:
71 apiGroup: rbac.authorization.k8s.io
72 kind: Role
73 name: {{ $saName }}
74subjects:
75 - kind: ServiceAccount
76 name: {{ $saName }}
77 namespace: {{ $saNamespace }}
78---
79apiVersion: rbac.authorization.k8s.io/v1beta1
80kind: Role
81metadata:
82 name: {{ $saName }}
83 namespace: {{ $saNamespace }}
84 labels:
85{{ tuple $saName $context | include "cdn-remote.metadata_labels" | indent 4 }}
86rules:
87 - apiGroups:
88 - ""
89 - extensions
90 - batch
91 - apps
92 verbs:
93 - get
94 - list
95 - patch
96 resources:
97 - statefulsets
98 - daemonsets
99 - jobs
100 - pods
101 - services
102 - endpoints
103 - configmaps
104{{- end -}}