blob: b4cbe09216a4df6f3804ae08191bb8eb1110803d [file] [log] [blame]
Woojoong Kimd3c132c2020-08-26 14:46:47 -07001{{- /*
2
3# Copyright 2020-present Open Networking Foundation
4#
5# SPDX-License-Identifier: Apache-2.0
6# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
7
8*/ -}}
9
10{{/*
11Renders a set of standardised labels
12*/}}
13{{- define "thingsboard-iot-platform.metadata_labels" -}}
14{{- $application := index . 0 -}}
15{{- $context := index . 1 -}}
16release: {{ $context.Release.Name }}
17app: {{ $application }}
18{{- end -}}
19
20{{/*
21Render the given template.
22*/}}
23{{- define "thingsboard-iot-platform.template" -}}
24{{- $name := index . 0 -}}
25{{- $context := index . 1 -}}
26{{- $last := base $context.Template.Name }}
27{{- $wtf := $context.Template.Name | replace $last $name -}}
28{{ include $wtf $context }}
29{{- end -}}
30
31{{/*
32Render ServiceAccount, Role, and RoleBinding required for kubernetes-entrypoint.
33*/}}
34{{- define "thingsboard-iot-platform.service_account" -}}
35{{- $context := index . 1 -}}
36{{- $saName := index . 0 -}}
37{{- $saNamespace := $context.Release.Namespace }}
38---
39apiVersion: v1
40kind: ServiceAccount
41metadata:
42 name: {{ $saName }}
43 namespace: {{ $saNamespace }}
44 labels:
45{{ tuple $saName $context | include "thingsboard-iot-platform.metadata_labels" | indent 4 }}
46---
Hyunsun Moondea0cb52021-02-19 16:53:22 -080047apiVersion: rbac.authorization.k8s.io/v1
Woojoong Kimd3c132c2020-08-26 14:46:47 -070048kind: RoleBinding
49metadata:
50 name: {{ $saName }}
51 namespace: {{ $saNamespace }}
52 labels:
53{{ tuple $saName $context | include "thingsboard-iot-platform.metadata_labels" | indent 4 }}
54roleRef:
55 apiGroup: rbac.authorization.k8s.io
56 kind: Role
57 name: {{ $saName }}
58subjects:
59 - kind: ServiceAccount
60 name: {{ $saName }}
61 namespace: {{ $saNamespace }}
62---
Hyunsun Moondea0cb52021-02-19 16:53:22 -080063apiVersion: rbac.authorization.k8s.io/v1
Woojoong Kimd3c132c2020-08-26 14:46:47 -070064kind: Role
65metadata:
66 name: {{ $saName }}
67 namespace: {{ $saNamespace }}
68 labels:
69{{ tuple $saName $context | include "thingsboard-iot-platform.metadata_labels" | indent 4 }}
70rules:
71 - apiGroups:
72 - ""
73 - extensions
74 - batch
75 - apps
76 verbs:
77 - get
78 - list
79 - patch
80 resources:
81 - statefulsets
82 - daemonsets
83 - jobs
84 - pods
85 - services
86 - endpoints
87 - configmaps
Hyunsun Moondea0cb52021-02-19 16:53:22 -080088{{- end -}}