blob: 6ba93e79cfe18bea4da70b5a0be8a6eee0986f38 [file] [log] [blame]
Woojoong Kimfdaa7732019-10-08 10:08:25 -07001{{- /*
2# Copyright 2018-present Open Networking Foundation
3# Copyright 2018 Intel Corporation
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16*/ -}}
17
18{{/*
19Renders a set of standardised labels
20*/}}
21{{- define "accelleran-cu.metadata_labels" -}}
22{{- $application := index . 0 -}}
23{{- $context := index . 1 -}}
24release: {{ $context.Release.Name }}
25app: {{ $application }}
26{{- end -}}
27
28{{/*
29Render ServiceAccount, Role, and RoleBinding required for kubernetes-entrypoint.
30*/}}
31{{- define "accelleran-cu.service_account" -}}
32{{- $context := index . 1 -}}
33{{- $saName := index . 0 -}}
34{{- $saNamespace := $context.Release.Namespace }}
35---
36apiVersion: v1
37kind: ServiceAccount
38metadata:
39 name: {{ $saName }}
40 namespace: {{ $saNamespace }}
41 labels:
42{{ tuple $saName $context | include "accelleran-cu.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 "accelleran-cu.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 "accelleran-cu.metadata_labels" | indent 4 }}
67{{- end -}}