blob: bb9854788bd27bce5e736e630eb0748a376e73c3 [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 Moon834c28f2019-12-05 18:26:22 -080040Return domain name 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 Moon834c28f2019-12-05 18:26:22 -080047{{- printf "%s.%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 Moon834c28f2019-12-05 18:26:22 -080051{{- printf "%s" $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 -}}
Hyunsun Moonec0b44d2020-01-10 15:50:53 -0700113
114{{/*
115Render init container for coredump.
116*/}}
117{{- define "omec-control-plane.coredump_init" -}}
118{{- $pod := index . 0 -}}
119{{- $context := index . 1 -}}
120- name: {{ $pod }}-coredump-init
121 image: {{ $context.Values.images.tags.init | quote }}
122 imagePullPolicy: {{ $context.Values.images.pullPolicy }}
123 securityContext:
124 privileged: true
125 runAsUser: 0
126 command: ["bash", "-xc"]
127 args:
128 - echo '/tmp/coredump/core.%h.%e.%t' > /mnt/host-rootfs/proc/sys/kernel/core_pattern
129 volumeMounts:
130 - name: host-rootfs
131 mountPath: /mnt/host-rootfs
132{{- end -}}