blob: fe44c87f0f8bd9c00fa7038f3695d12590fd4a64 [file] [log] [blame]
Jeremy Ronquillo223db002020-06-05 10:28:22 -07001{{- /*
Jeremy Ronquilloec2d3e42020-06-05 11:33:39 -07002
Jeremy Ronquillo223db002020-06-05 10:28:22 -07003# Copyright 2019-present Open Networking Foundation
4#
Jeremy Ronquillo6046ce32020-06-18 11:06:29 -07005# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
Jeremy Ronquilloec2d3e42020-06-05 11:33:39 -07006
Jeremy Ronquillo223db002020-06-05 10:28:22 -07007*/ -}}
8
9{{/*
10Render a set of standardised label
11*/}}
12{{- define "accelleran-cbrs-common.metadata_labels" -}}
13{{- $application := index . 0 -}}
14{{- $context := index . 1 -}}
15release: {{ $context.Release.Name }}
16app: {{ $application }}
17{{- end -}}
18
19{{/*
20Render ServiceAccount, Role, and RoleBinding required for kubernetes-entrypoint.
21*/}}
22{{- define "accelleran-cbrs-common.service_account" -}}
23{{- $context := index . 1 -}}
24{{- $saName := index . 0 -}}
25{{- $saNamespace := $context.Release.Namespace }}
26---
27apiVersion: v1
28kind: ServiceAccount
29metadata:
30 name: {{ $saName }}
31 namespace: {{ $saNamespace }}
32 labels:
33{{ tuple $saName $context | include "accelleran-cbrs-common.metadata_labels" | indent 4 }}
34---
Hyunsun Moond457d182020-09-10 15:52:09 -070035{{- if semverCompare ">=1.16-0" $context.Capabilities.KubeVersion.GitVersion }}
36apiVersion: rbac.authorization.k8s.io/v1
37{{- else }}
Jeremy Ronquillo223db002020-06-05 10:28:22 -070038apiVersion: rbac.authorization.k8s.io/v1beta1
Hyunsun Moond457d182020-09-10 15:52:09 -070039{{- end }}
Jeremy Ronquillo223db002020-06-05 10:28:22 -070040kind: RoleBinding
41metadata:
42 name: {{ $saName }}
43 namespace: {{ $saNamespace }}
44 labels:
45{{ tuple $saName $context | include "accelleran-cbrs-common.metadata_labels" | indent 4 }}
46roleRef:
47 apiGroup: rbac.authorization.k8s.io
48 kind: Role
49 name: {{ $saName }}
50subjects:
51 - kind: ServiceAccount
52 name: {{ $saName }}
53 namespace: {{ $saNamespace }}
54---
Hyunsun Moond457d182020-09-10 15:52:09 -070055{{- if semverCompare ">=1.16-0" $context.Capabilities.KubeVersion.GitVersion }}
56apiVersion: rbac.authorization.k8s.io/v1
57{{- else }}
Jeremy Ronquillo223db002020-06-05 10:28:22 -070058apiVersion: rbac.authorization.k8s.io/v1beta1
Hyunsun Moond457d182020-09-10 15:52:09 -070059{{- end }}
Jeremy Ronquillo223db002020-06-05 10:28:22 -070060kind: Role
61metadata:
62 name: {{ $saName }}
63 namespace: {{ $saNamespace }}
64 labels:
65{{ tuple $saName $context | include "accelleran-cbrs-common.metadata_labels" | indent 4 }}
66rules:
67 - apiGroups:
68 - ""
69 - extensions
70 - batch
71 - apps
72 verbs:
73 - get
74 - list
75 - patch
76 resources:
77 - statefulsets
78 - daemonsets
79 - jobs
80 - pods
81 - services
82 - endpoints
83 - configmaps
Jeremy Ronquillo6046ce32020-06-18 11:06:29 -070084{{- end -}}