added repo
This commit is contained in:
@@ -0,0 +1,388 @@
|
||||
{{/* vim: set filetype=mustache: */}}
|
||||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "vmalert.name" -}}
|
||||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Maintainer - Akshay Gupta
|
||||
Tolerations and nodeSelector via Resources Requests.
|
||||
*/}}
|
||||
{{- define "meesho.server.getCpu" -}}
|
||||
{{- $cpu := toString .Values.server.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.server.getMem" -}}
|
||||
{{- $mem := toString .Values.server.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.server.getRatio" -}}
|
||||
{{- $cpu := (include "meesho.server.getCpu" .) -}}
|
||||
{{- $mem := (include "meesho.server.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.server.dedicatedValue" -}}
|
||||
{{- if (index .Values.server.labels "arch") -}}
|
||||
{{- if (index .Values.server.labels "runpod") -}}
|
||||
{{- $cpu := (include "meesho.server.getCpu" .) -}}
|
||||
{{- $mem := (include "meesho.server.getMem" .) -}}
|
||||
{{- $ratio := (include "meesho.server.getRatio" .) -}}
|
||||
{{- $arch := .Values.server.labels.arch -}}
|
||||
{{- $runPod := .Values.server.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 -}}
|
||||
|
||||
{{/*
|
||||
Maintainer - Akshay Gupta
|
||||
Tolerations and nodeSelector via Resources Requests.
|
||||
*/}}
|
||||
{{- define "meesho.alertmanager.getCpu" -}}
|
||||
{{- $cpu := toString .Values.alertmanager.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.alertmanager.getMem" -}}
|
||||
{{- $mem := toString .Values.alertmanager.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.alertmanager.getRatio" -}}
|
||||
{{- $cpu := (include "meesho.alertmanager.getCpu" .) -}}
|
||||
{{- $mem := (include "meesho.alertmanager.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.alertmanager.dedicatedValue" -}}
|
||||
{{- if (index .Values.alertmanager.labels "arch") -}}
|
||||
{{- if (index .Values.alertmanager.labels "runpod") -}}
|
||||
{{- $cpu := (include "meesho.alertmanager.getCpu" .) -}}
|
||||
{{- $mem := (include "meesho.alertmanager.getMem" .) -}}
|
||||
{{- $ratio := (include "meesho.alertmanager.getRatio" .) -}}
|
||||
{{- $arch := .Values.alertmanager.labels.arch -}}
|
||||
{{- $runPod := .Values.alertmanager.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 "vmalert.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 "vmalert.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create unified labels for vmalert components
|
||||
*/}}
|
||||
{{- define "vmalert.common.matchLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "vmalert.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "vmalert.common.metaLabels" -}}
|
||||
helm.sh/chart: {{ include "vmalert.chart" . }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "vmalert.server.labels" -}}
|
||||
{{- toYaml .Values.server.labels | nindent 0 }}
|
||||
{{ include "vmalert.server.matchLabels" . }}
|
||||
{{ include "vmalert.common.metaLabels" . }}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "vmalert.server.matchLabels" -}}
|
||||
app: {{ .Values.server.name }}
|
||||
{{ include "vmalert.common.matchLabels" . }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create a fully qualified server name.
|
||||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||
*/}}
|
||||
{{- define "vmalert.server.fullname" -}}
|
||||
{{- if .Values.server.fullnameOverride -}}
|
||||
{{- .Values.server.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
||||
{{- if contains $name .Release.Name -}}
|
||||
{{- printf "%s-%s" .Release.Name .Values.server.name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s-%s-%s" .Release.Name $name .Values.server.name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
{{- define "vmalert.server.configname" -}}
|
||||
{{- if .Values.server.configMap -}}
|
||||
{{- .Values.server.configMap -}}
|
||||
{{- else -}}
|
||||
{{- include "vmalert.server.fullname" . -}}-alert-rules-config
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "vmalert.serviceAccountName" -}}
|
||||
{{- if .Values.serviceAccount.create -}}
|
||||
{{ default (include "vmalert.fullname" .) .Values.serviceAccount.name }}
|
||||
{{- else -}}
|
||||
{{ default "default" .Values.serviceAccount.name }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
|
||||
{{- define "vmalert.alertmanager.labels" -}}
|
||||
{{- toYaml .Values.alertmanager.labels | nindent 0 }}
|
||||
{{ include "vmalert.alertmanager.matchLabels" . }}
|
||||
{{ include "vmalert.common.metaLabels" . }}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "vmalert.alertmanager.matchLabels" -}}
|
||||
app: alertmanager
|
||||
{{ include "vmalert.common.matchLabels" . }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create a fully qualified server name.
|
||||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||
*/}}
|
||||
{{- define "vmalert.alertmanager.fullname" -}}
|
||||
{{- if .Values.alertmanager.fullnameOverride -}}
|
||||
{{- .Values.alertmanager.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
||||
{{- if contains $name .Release.Name -}}
|
||||
{{- printf "%s-%s" .Release.Name .Values.alertmanager.name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s-%s-%s" .Release.Name $name .Values.alertmanager.name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "vmalert.alertmanager.configname" -}}
|
||||
{{- if .Values.alertmanager.configMap -}}
|
||||
{{- .Values.alertmanager.configMap -}}
|
||||
{{- else -}}
|
||||
{{- include "vmalert.alertmanager.fullname" . -}}-alertmanager-config
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "vmalert.alertmanager.url" -}}
|
||||
{{- if .Values.alertmanager.enabled -}}
|
||||
http://{{- include "vmalert.alertmanager.fullname" . -}}:9093
|
||||
{{- else -}}
|
||||
{{- .Values.server.notifier.alertmanager.url -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "vmalert.alertmanager.urls" -}}
|
||||
{{- $urls := list -}}
|
||||
{{- with (include "vmalert.alertmanager.url" .) -}}
|
||||
{{- $urls = append $urls . -}}
|
||||
{{- end -}}
|
||||
{{- range .Values.server.notifiers }}
|
||||
{{- if not (eq .alertmanager.url "") -}}
|
||||
{{- $urls = append $urls .alertmanager.url -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- join "," $urls }}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "vmalert.alertmanager.passwords" -}}
|
||||
{{- $password := list -}}
|
||||
{{- if .Values.alertmanager.enabled -}}
|
||||
{{- $password = append $password "" -}}
|
||||
{{- end -}}
|
||||
{{- $notifiers := append .Values.server.notifiers .Values.server.notifier }}
|
||||
{{- range $notifiers }}
|
||||
{{- if not (eq .alertmanager.url "") -}}
|
||||
{{- if and .alertmanager.basicAuth .alertmanager.basicAuth.password -}}
|
||||
{{- $password = append $password .alertmanager.basicAuth.password -}}
|
||||
{{- else -}}
|
||||
{{- $password = append $password "" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{ include "_vmalert.optionalPrintList" $password }}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "vmalert.alertmanager.usernames" -}}
|
||||
{{- $usernames := list -}}
|
||||
{{- if .Values.alertmanager.enabled -}}
|
||||
{{- $usernames = append $usernames "" -}}
|
||||
{{- end -}}
|
||||
{{- $notifiers := append .Values.server.notifiers .Values.server.notifier }}
|
||||
{{- range $notifiers }}
|
||||
{{- if not (eq .alertmanager.url "") -}}
|
||||
{{- if and .alertmanager.basicAuth .alertmanager.basicAuth.username -}}
|
||||
{{- $usernames = append $usernames .alertmanager.basicAuth.username -}}
|
||||
{{- else -}}
|
||||
{{- $usernames = append $usernames "" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{ include "_vmalert.optionalPrintList" $usernames }}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "vmalert.alertmanager.bearerTokens" -}}
|
||||
{{- $tokens := list -}}
|
||||
{{- if .Values.alertmanager.enabled -}}
|
||||
{{- $tokens = append $tokens "" -}}
|
||||
{{- end -}}
|
||||
{{- $notifiers := append .Values.server.notifiers .Values.server.notifier }}
|
||||
{{- range $notifiers }}
|
||||
{{- if not (eq .alertmanager.url "") -}}
|
||||
{{- if and .alertmanager.bearer .alertmanager.bearer.token -}}
|
||||
{{- $tokens = append $tokens .alertmanager.bearer.token -}}
|
||||
{{- else -}}
|
||||
{{- $tokens = append $tokens "" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{ include "_vmalert.optionalPrintList" $tokens }}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
{{- define "vmalert.alertmanager.bearerTokenFiles" -}}
|
||||
{{- $files := list -}}
|
||||
{{- if .Values.alertmanager.enabled -}}
|
||||
{{- $files = append $files "" -}}
|
||||
{{- end -}}
|
||||
{{- $notifiers := append .Values.server.notifiers .Values.server.notifier }}
|
||||
{{- range $notifiers }}
|
||||
{{- if not (eq .alertmanager.url "") -}}
|
||||
{{- if and .alertmanager.bearer .alertmanager.bearer.tokenFile -}}
|
||||
{{- $files = append $files .alertmanager.bearer.tokenFile -}}
|
||||
{{- else -}}
|
||||
{{- $files = append $files "" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{ include "_vmalert.optionalPrintList" $files }}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "_vmalert.optionalPrintList" }}
|
||||
{{- $str := join "," . -}}
|
||||
{{- $cleared := $str | replace "," "" | trim -}}
|
||||
{{- if eq $cleared "" -}}
|
||||
{{ $cleared }}
|
||||
{{- else -}}
|
||||
{{ $str }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
{{/*
|
||||
Return the appropriate apiVersion for ingress.
|
||||
*/}}
|
||||
{{- define "vmalert.ingress.apiVersion" -}}
|
||||
{{- if and (.Capabilities.APIVersions.Has "networking.k8s.io/v1") -}}
|
||||
{{- print "networking.k8s.io/v1" -}}
|
||||
{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" -}}
|
||||
{{- print "networking.k8s.io/v1beta1" -}}
|
||||
{{- else -}}
|
||||
{{- print "extensions/v1beta1" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return if ingress is stable.
|
||||
*/}}
|
||||
{{- define "vmalert.ingress.isStable" -}}
|
||||
{{- eq (include "vmalert.ingress.apiVersion" .) "networking.k8s.io/v1" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return if ingress supports ingressClassName.
|
||||
*/}}
|
||||
{{- define "vmalert.ingress.supportsIngressClassName" -}}
|
||||
{{- or (eq (include "vmalert.ingress.isStable" .) "true") (and (eq (include "vmalert.ingress.apiVersion" .) "networking.k8s.io/v1beta1")) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return if ingress supports pathType.
|
||||
*/}}
|
||||
{{- define "vmalert.ingress.supportsPathType" -}}
|
||||
{{- or (eq (include "vmalert.ingress.isStable" .) "true") (and (eq (include "vmalert.ingress.apiVersion" .) "networking.k8s.io/v1beta1")) -}}
|
||||
{{- end -}}
|
||||
Reference in New Issue
Block a user