blob: 53bd471d9e53d05566e730fe28d02229e7d863ab [file] [log] [blame]
Wei-Yu Chen0f12b9c2019-04-18 11:12:59 -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
Wei-Yu Chen0f12b9c2019-04-18 11:12:59 -070018{{/*
Hyunsun Moon7a007bb2019-08-19 16:41:36 -060019Renders a set of standardised labels
Wei-Yu Chen0f12b9c2019-04-18 11:12:59 -070020*/}}
Hyunsun Moon7a007bb2019-08-19 16:41:36 -060021{{- define "omec-control-plane.metadata_labels" -}}
Hyunsun Moon06f98552019-08-15 13:44:47 -060022{{- $application := index . 0 -}}
23{{- $context := index . 1 -}}
24release: {{ $context.Release.Name }}
25app: {{ $application }}
Wei-Yu Chen0f12b9c2019-04-18 11:12:59 -070026{{- end -}}
Hyunsun Moona24d3f92019-06-19 03:04:58 -050027
28{{/*
29Render the given template.
30*/}}
Hyunsun Moon7a007bb2019-08-19 16:41:36 -060031{{- define "omec-control-plane.template" -}}
Hyunsun Moona24d3f92019-06-19 03:04:58 -050032{{- $name := index . 0 -}}
33{{- $context := index . 1 -}}
34{{- $last := base $context.Template.Name }}
35{{- $wtf := $context.Template.Name | replace $last $name -}}
36{{ include $wtf $context }}
37{{- end -}}
Hyunsun Moon636e17d2019-07-03 12:52:15 -050038
39{{/*
Hyunsun Moon2eede662019-10-11 13:11:44 -060040Return s6a service for Diameter identity, realm, and hostname for a given application.
Hyunsun Moon636e17d2019-07-03 12:52:15 -050041*/}}
Hyunsun Moon2eede662019-10-11 13:11:44 -060042{{- define "omec-control-plane.diameter_endpoint" -}}
Hyunsun Moon636e17d2019-07-03 12:52:15 -050043{{- $service := index . 0 -}}
44{{- $type := index . 1 -}}
45{{- $context := index . 2 -}}
Hyunsun Moon636e17d2019-07-03 12:52:15 -050046{{- if eq $type "identity" -}}
Hyunsun Moone03ddf42019-12-01 19:28:53 -080047{{- printf "%s-s6a.%s.svc.%s" $service $context.Release.Namespace $context.Values.config.clusterDomain -}}
Hyunsun Moon636e17d2019-07-03 12:52:15 -050048{{- else if eq $type "realm" -}}
Hyunsun Moone03ddf42019-12-01 19:28:53 -080049{{- printf "%s.svc.%s" $context.Release.Namespace $context.Values.config.clusterDomain -}}
Hyunsun Moon636e17d2019-07-03 12:52:15 -050050{{- else if eq $type "host" -}}
Hyunsun Moon2eede662019-10-11 13:11:44 -060051{{- printf "%s-s6a" $service -}}
Hyunsun Moon636e17d2019-07-03 12:52:15 -050052{{- end -}}
53{{- end -}}
Hyunsun Moon16d70922019-08-25 04:57:25 -050054
55{{/*
56Render ServiceAccount, Role, and RoleBinding required for kubernetes-entrypoint.
57*/}}
58{{- define "omec-control-plane.service_account" -}}
59{{- $context := index . 1 -}}
60{{- $saName := index . 0 -}}
61{{- $saNamespace := $context.Release.Namespace }}
62---
63apiVersion: v1
64kind: ServiceAccount
65metadata:
66 name: {{ $saName }}
67 namespace: {{ $saNamespace }}
68 labels:
69{{ tuple $saName $context | include "omec-control-plane.metadata_labels" | indent 4 }}
70---
71apiVersion: rbac.authorization.k8s.io/v1beta1
72kind: RoleBinding
73metadata:
74 name: {{ $saName }}
75 namespace: {{ $saNamespace }}
76 labels:
77{{ tuple $saName $context | include "omec-control-plane.metadata_labels" | indent 4 }}
78roleRef:
79 apiGroup: rbac.authorization.k8s.io
80 kind: Role
81 name: {{ $saName }}
82subjects:
83 - kind: ServiceAccount
84 name: {{ $saName }}
85 namespace: {{ $saNamespace }}
86---
87apiVersion: rbac.authorization.k8s.io/v1beta1
88kind: Role
89metadata:
90 name: {{ $saName }}
91 namespace: {{ $saNamespace }}
92 labels:
93{{ tuple $saName $context | include "omec-control-plane.metadata_labels" | indent 4 }}
94rules:
95 - apiGroups:
96 - ""
97 - extensions
98 - batch
99 - apps
100 verbs:
101 - get
102 - list
103 - patch
104 resources:
105 - statefulsets
106 - daemonsets
107 - jobs
108 - pods
109 - services
110 - endpoints
111 - configmaps
112{{- end -}}