158 lines
4.3 KiB
Smarty
158 lines
4.3 KiB
Smarty
{{/* vim: set filetype=mustache: */}}
|
|
{{/*
|
|
Expand the name of the chart.
|
|
*/}}
|
|
{{- define "alertmanager.name" -}}
|
|
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
|
|
{{- end }}
|
|
|
|
{{/*
|
|
Maintainer - Akshay Gupta
|
|
Tolerations and nodeSelector via Resources Requests.
|
|
*/}}
|
|
{{- define "meesho.getCpu" -}}
|
|
{{- $cpu := toString .Values.resources.requests.cpu -}}
|
|
{{- if contains "m" $cpu -}}
|
|
{{- $cpu := trimAll "m" $cpu | float64 -}}
|
|
{{- $cpu := $cpu | float64 -}}
|
|
{{- printf "%f" $cpu -}}
|
|
{{- else -}}
|
|
{{- $cpu := mulf $cpu 1000.000 -}}
|
|
{{- printf "%f" $cpu -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- define "meesho.getMem" -}}
|
|
{{- $mem := toString .Values.resources.requests.memory -}}
|
|
{{- if contains "Mi" $mem -}}
|
|
{{- $mem := trimAll "Mi" $mem | float64 -}}
|
|
{{- printf "%f" $mem -}}
|
|
{{- else if contains "Gi" $mem -}}
|
|
{{- $mem := trimAll "Gi" $mem | float64 -}}
|
|
{{- $mem := mulf $mem 1024.000 -}}
|
|
{{- printf "%f" $mem -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- define "meesho.getRatio" -}}
|
|
{{- $cpu := (include "meesho.getCpu" .) -}}
|
|
{{- $mem := (include "meesho.getMem" .) -}}
|
|
{{- $ratio := divf $mem $cpu -}}
|
|
{{- if gt $ratio 4.00 -}}
|
|
{{- printf "1to8" -}}
|
|
{{- else if gt $ratio 2.00 -}}
|
|
{{- printf "1to4" -}}
|
|
{{- else -}}
|
|
{{- printf "1to2" -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- define "meesho.dedicatedValue" -}}
|
|
{{- if (index .Values.labels "arch") -}}
|
|
{{- if (index .Values.labels "runpod") -}}
|
|
{{- $cpu := (include "meesho.getCpu" .) -}}
|
|
{{- $mem := (include "meesho.getMem" .) -}}
|
|
{{- $ratio := (include "meesho.getRatio" .) -}}
|
|
{{- $arch := .Values.labels.arch -}}
|
|
{{- $runPod := .Values.labels.runpod -}}
|
|
{{- printf "%s-%s-%s" $ratio $arch $runPod -}}
|
|
{{- else -}}
|
|
{{- printf "missing-runpod-label" -}}
|
|
{{- end -}}
|
|
{{- else -}}
|
|
{{- printf "missing-arch-label" -}}
|
|
{{- end -}}
|
|
{{/*- printf "%s-%s-%s-%s-%s" $ratio $arch $runPod $cpu $mem -*/}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Create a default fully qualified app name.
|
|
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
|
If release name contains chart name it will be used as a full name.
|
|
*/}}
|
|
{{- define "alertmanager.fullname" -}}
|
|
{{- if .Values.fullnameOverride }}
|
|
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
|
|
{{- else }}
|
|
{{- $name := default .Chart.Name .Values.nameOverride }}
|
|
{{- if contains $name .Release.Name }}
|
|
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
|
|
{{- else }}
|
|
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
|
|
{{/*
|
|
Create chart name and version as used by the chart label.
|
|
*/}}
|
|
{{- define "alertmanager.chart" -}}
|
|
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
|
{{- end }}
|
|
|
|
{{/*
|
|
Common labels
|
|
*/}}
|
|
{{- define "alertmanager.labels" -}}
|
|
helm.sh/chart: {{ include "alertmanager.chart" . }}
|
|
{{ include "alertmanager.selectorLabels" . }}
|
|
{{- with .Chart.AppVersion }}
|
|
app.kubernetes.io/version: {{ . | quote }}
|
|
{{- end }}
|
|
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
|
{{- end }}
|
|
|
|
{{/*
|
|
Selector labels
|
|
*/}}
|
|
{{- define "alertmanager.selectorLabels" -}}
|
|
app.kubernetes.io/name: {{ include "alertmanager.name" . }}
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
{{- end }}
|
|
|
|
{{/*
|
|
Create the name of the service account to use
|
|
*/}}
|
|
{{- define "alertmanager.serviceAccountName" -}}
|
|
{{- if .Values.serviceAccount.create }}
|
|
{{- default (include "alertmanager.fullname" .) .Values.serviceAccount.name }}
|
|
{{- else }}
|
|
{{- default "default" .Values.serviceAccount.name }}
|
|
{{- end }}
|
|
{{- end }}
|
|
|
|
{{/*
|
|
Define Ingress apiVersion
|
|
*/}}
|
|
{{- define "alertmanager.ingress.apiVersion" -}}
|
|
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion }}
|
|
{{- printf "networking.k8s.io/v1" }}
|
|
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion }}
|
|
{{- printf "networking.k8s.io/v1beta1" }}
|
|
{{- else }}
|
|
{{- printf "extensions/v1beta1" }}
|
|
{{- end }}
|
|
{{- end }}
|
|
|
|
{{/*
|
|
Define Pdb apiVersion
|
|
*/}}
|
|
{{- define "alertmanager.pdb.apiVersion" -}}
|
|
{{- if $.Capabilities.APIVersions.Has "policy/v1/PodDisruptionBudget" }}
|
|
{{- printf "policy/v1" }}
|
|
{{- else }}
|
|
{{- printf "policy/v1beta1" }}
|
|
{{- end }}
|
|
{{- end }}
|
|
|
|
{{/*
|
|
Allow overriding alertmanager namespace
|
|
*/}}
|
|
{{- define "alertmanager.namespace" -}}
|
|
{{- if .Values.namespaceOverride -}}
|
|
{{- .Values.namespaceOverride -}}
|
|
{{- else -}}
|
|
{{- .Release.Namespace -}}
|
|
{{- end -}}
|
|
{{- end -}}
|