blob: 193d461caff50f8d67b6061813fdc4d077213a70 [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-local.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-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{{/*
29Render 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---
36apiVersion: v1
37kind: ServiceAccount
38metadata:
39 name: {{ $saName }}
40 namespace: {{ $saNamespace }}
41 labels:
42{{ tuple $saName $context | include "cdn-local.metadata_labels" | indent 4 }}
43---
44apiVersion: rbac.authorization.k8s.io/v1beta1
45kind: RoleBinding
46metadata:
47 name: {{ $saName }}
48 namespace: {{ $saNamespace }}
49 labels:
50{{ tuple $saName $context | include "cdn-local.metadata_labels" | indent 4 }}
51roleRef:
52 apiGroup: rbac.authorization.k8s.io
53 kind: Role
54 name: {{ $saName }}
55subjects:
56 - kind: ServiceAccount
57 name: {{ $saName }}
58 namespace: {{ $saNamespace }}
59---
60apiVersion: rbac.authorization.k8s.io/v1beta1
61kind: Role
62metadata:
63 name: {{ $saName }}
64 namespace: {{ $saNamespace }}
65 labels:
66{{ tuple $saName $context | include "cdn-local.metadata_labels" | indent 4 }}
67rules:
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 Ronquillo6046ce32020-06-18 11:06:29 -070085{{- end -}}