blob: be7fc5fdcc99fdadef48c5621cb81d503d8039f4 [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 2018 Intel Corporation
Jeremy Ronquilloec2d3e42020-06-05 11:33:39 -07004# Copyright 2018-present Open Networking Foundation
Jeremy Ronquillo223db002020-06-05 10:28:22 -07005#
Jeremy Ronquilloec2d3e42020-06-05 11:33:39 -07006# SPDX-License-Identifier: Apache-2.0
Jeremy Ronquillo6046ce32020-06-18 11:06:29 -07007# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
Jeremy Ronquilloec2d3e42020-06-05 11:33:39 -07008
Jeremy Ronquillo223db002020-06-05 10:28:22 -07009*/ -}}
10
11{{/*
12Renders a set of standardised labels
13*/}}
14{{- define "omec-control-plane.metadata_labels" -}}
15{{- $application := index . 0 -}}
16{{- $context := index . 1 -}}
17release: {{ $context.Release.Name }}
18app: {{ $application }}
19{{- end -}}
20
21{{/*
22Render the given template.
23*/}}
24{{- define "omec-control-plane.template" -}}
25{{- $name := index . 0 -}}
26{{- $context := index . 1 -}}
27{{- $last := base $context.Template.Name }}
28{{- $wtf := $context.Template.Name | replace $last $name -}}
29{{ include $wtf $context }}
30{{- end -}}
31
32{{/*
33Return domain name for Diameter identity, realm, and hostname for a given application.
34*/}}
35{{- define "omec-control-plane.diameter_endpoint" -}}
36{{- $service := index . 0 -}}
37{{- $type := index . 1 -}}
38{{- $context := index . 2 -}}
39{{- if eq $type "identity" -}}
40{{- printf "%s.%s.svc.%s" $service $context.Release.Namespace $context.Values.config.clusterDomain -}}
41{{- else if eq $type "realm" -}}
42{{- printf "%s.svc.%s" $context.Release.Namespace $context.Values.config.clusterDomain -}}
43{{- else if eq $type "host" -}}
44{{- printf "%s" $service -}}
45{{- end -}}
46{{- end -}}
47
48{{/*
49Render ServiceAccount, Role, and RoleBinding required for kubernetes-entrypoint.
50*/}}
51{{- define "omec-control-plane.service_account" -}}
52{{- $context := index . 1 -}}
53{{- $saName := index . 0 -}}
54{{- $saNamespace := $context.Release.Namespace }}
55---
56apiVersion: v1
57kind: ServiceAccount
58metadata:
59 name: {{ $saName }}
60 namespace: {{ $saNamespace }}
61 labels:
62{{ tuple $saName $context | include "omec-control-plane.metadata_labels" | indent 4 }}
63---
Hyunsun Moond457d182020-09-10 15:52:09 -070064{{- if semverCompare ">=1.16-0" $context.Capabilities.KubeVersion.GitVersion }}
65apiVersion: rbac.authorization.k8s.io/v1
66{{- else }}
Jeremy Ronquillo223db002020-06-05 10:28:22 -070067apiVersion: rbac.authorization.k8s.io/v1beta1
Hyunsun Moond457d182020-09-10 15:52:09 -070068{{- end }}
Jeremy Ronquillo223db002020-06-05 10:28:22 -070069kind: RoleBinding
70metadata:
71 name: {{ $saName }}
72 namespace: {{ $saNamespace }}
73 labels:
74{{ tuple $saName $context | include "omec-control-plane.metadata_labels" | indent 4 }}
75roleRef:
76 apiGroup: rbac.authorization.k8s.io
77 kind: Role
78 name: {{ $saName }}
79subjects:
80 - kind: ServiceAccount
81 name: {{ $saName }}
82 namespace: {{ $saNamespace }}
83---
Hyunsun Moond457d182020-09-10 15:52:09 -070084{{- if semverCompare ">=1.16-0" $context.Capabilities.KubeVersion.GitVersion }}
85apiVersion: rbac.authorization.k8s.io/v1
86{{- else }}
Jeremy Ronquillo223db002020-06-05 10:28:22 -070087apiVersion: rbac.authorization.k8s.io/v1beta1
Hyunsun Moond457d182020-09-10 15:52:09 -070088{{- end }}
Jeremy Ronquillo223db002020-06-05 10:28:22 -070089kind: Role
90metadata:
91 name: {{ $saName }}
92 namespace: {{ $saNamespace }}
93 labels:
94{{ tuple $saName $context | include "omec-control-plane.metadata_labels" | indent 4 }}
95rules:
96 - apiGroups:
97 - ""
98 - extensions
99 - batch
100 - apps
101 verbs:
102 - get
103 - list
104 - patch
105 resources:
106 - statefulsets
107 - daemonsets
108 - jobs
109 - pods
110 - services
111 - endpoints
112 - configmaps
113{{- end -}}
114
115{{/*
116Render init container for coredump.
117*/}}
118{{- define "omec-control-plane.coredump_init" -}}
119{{- $pod := index . 0 -}}
120{{- $context := index . 1 -}}
121- name: {{ $pod }}-coredump-init
122 image: {{ $context.Values.images.tags.init | quote }}
123 imagePullPolicy: {{ $context.Values.images.pullPolicy }}
124 securityContext:
125 privileged: true
126 runAsUser: 0
Hyunsun Moonb0c8bcc2021-09-09 09:33:26 -0700127 command: ["sh", "-xc"]
Jeremy Ronquillo223db002020-06-05 10:28:22 -0700128 args:
129 - echo '/tmp/coredump/core.%h.%e.%t' > /mnt/host-rootfs/proc/sys/kernel/core_pattern
130 volumeMounts:
131 - name: host-rootfs
132 mountPath: /mnt/host-rootfs
133{{- end -}}