added repo

This commit is contained in:
Your Name
2026-08-26 03:39:42 +05:30
parent 45c25a95af
commit b8575bb8b9
6889 changed files with 1217125 additions and 0 deletions
@@ -0,0 +1,88 @@
{{- if .Values.printNotes }}
{{- $ctx := dict "helm" . "style" "plain" }}
{{- $ns := include "vm.namespace" $ctx }}
{{- if .Values.vminsert.enabled }}
{{- if .Values.vmauth.enabled }}
{{- $_ := set $ctx "appKey" "vmauth" }}
{{- else }}
{{- $_ := set $ctx "appKey" "vminsert" }}
{{- end }}
{{- $fullname := include "vm.plain.fullname" $ctx }}
Write API:
The Victoria Metrics write api can be accessed via port {{ .Values.vminsert.service.servicePort }} with the following DNS name from within your cluster:
{{ include "vm.fqdn" $ctx }}
Get the Victoria Metrics insert service URL by running these commands in the same shell:
{{- if contains "NodePort" .Values.vminsert.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ $ns }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ $fullname }})
export NODE_IP=$(kubectl get nodes --namespace {{ $ns }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.vminsert.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get svc --namespace {{ $ns }} -w {{ $fullname }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ $ns }} {{ $fullname }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.vminsert.service.servicePort }}
{{- else if contains "ClusterIP" .Values.vminsert.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ $ns }} -l "app={{ .Values.vminsert.name }}" -o jsonpath="{.items[0].metadata.name}")
kubectl --namespace {{ $ns }} port-forward $POD_NAME {{ .Values.vminsert.service.servicePort }}
{{- end }}
You need to update your Prometheus configuration file and add the following lines to it:
prometheus.yml
remote_write:
- url: "http://<insert-service>/insert/0/prometheus/"
for example - inside the Kubernetes cluster:
remote_write:
- url: {{ include "vm.url" $ctx }}/insert/0/prometheus/
{{- end }}
{{- if .Values.vmselect.enabled }}
{{- if .Values.vmauth.enabled }}
{{- $_ := set $ctx "appKey" "vmauth" }}
{{- else }}
{{- $_ := set $ctx "appKey" "vmselect" }}
{{- end }}
{{- $fullname := include "vm.plain.fullname" $ctx }}
Read API:
The VictoriaMetrics read api can be accessed via port {{ .Values.vmselect.service.servicePort }} with the following DNS name from within your cluster:
{{ include "vm.fqdn" $ctx }}
Get the VictoriaMetrics select service URL by running these commands in the same shell:
{{- if contains "NodePort" .Values.vmselect.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ $ns }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ $fullname }})
export NODE_IP=$(kubectl get nodes --namespace {{ $ns }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.vmselect.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get svc --namespace {{ $ns }} -w {{ $fullname }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ $ns }} {{ $fullname }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.vmselect.service.servicePort }}
{{- else if contains "ClusterIP" .Values.vmselect.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ $ns }} -l "app={{ .Values.vmselect.name }}" -o jsonpath="{.items[0].metadata.name}")
kubectl --namespace {{ $ns }} port-forward $POD_NAME {{ .Values.vmselect.service.servicePort }}
{{- end }}
You need to specify select service URL into your Grafana:
NOTE: you need to use the Prometheus Data Source
Input this URL field into Grafana
http://<select-service>/select/0/prometheus/
for example - inside the Kubernetes cluster:
{{ include "vm.url" $ctx }}/select/0/prometheus/
{{- end }}
{{- end }}
@@ -0,0 +1,272 @@
{{- define "vminsert.relabel.config.name" -}}
{{- $Values := (.helm).Values | default .Values -}}
{{- $app := $Values.vminsert }}
{{- $fullname := include "vm.plain.fullname" . -}}
{{- $app.relabel.configMap | default (printf "%s-relabelconfig" $fullname) -}}
{{- end -}}
{{- define "vminsert.args" -}}
{{- $Values := (.helm).Values | default .Values -}}
{{- $app := $Values.vminsert -}}
{{- $args := default dict -}}
{{- $_ := set . "style" "plain" }}
{{- $_ := set . "appKey" "vmstorage" }}
{{- $args = mergeOverwrite $args (fromYaml (include "vm.license.flag" .)) -}}
{{- $args = mergeOverwrite $args $app.extraArgs -}}
{{- $storage := $Values.vmstorage }}
{{- if and (not $app.suppressStorageFQDNsRender) $storage.enabled $storage.replicaCount }}
{{- $storageNodes := default list }}
{{- $fqdn := include "vm.fqdn" . }}
{{- if $Values.autoDiscovery }}
{{- if eq (include "vm.enterprise.disabled" . ) "true" }}
{{- fail "SRV autodiscovery is only supported in enterprise. Either define license or set `autoDiscovery` to `false`" }}
{{- end }}
{{- $storageNode := printf "srv+_vminsert._tcp.%s" $fqdn }}
{{- $storageNodes = append $storageNodes $storageNode }}
{{- else }}
{{- $port := "8400" }}
{{- range $i := until ($storage.replicaCount | int) -}}
{{- if not (has (float64 $i) $app.excludeStorageIDs) -}}
{{- $_ := set $ "appIdx" $i }}
{{- $storageNode := include "vm.fqdn" $ -}}
{{- $storageNodes = append $storageNodes (printf "%s:%s" $storageNode $port) -}}
{{- end -}}
{{- end -}}
{{- $_ := unset $ "appIdx" }}
{{- end }}
{{- $_ := set $args "storageNode" (concat ($args.storageNode | default list) $storageNodes) }}
{{- end -}}
{{- if $app.relabel.enabled -}}
{{- $_ := set $args "relabelConfig" "/relabelconfig/relabel.yml" -}}
{{- end -}}
{{- if empty $args.storageNode }}
{{- fail "no storageNodes found. Either set vmstorage.enabled to true or add nodes to vminsert.extraArgs.storageNode"}}
{{- end }}
{{- toYaml (fromYaml (include "vm.args" $args)).args -}}
{{- end -}}
{{- define "vmauth.args" -}}
{{- $Values := (.helm).Values | default .Values }}
{{- $app := $Values.vmauth -}}
{{- $args := default dict -}}
{{- $_ := set $args "auth.config" "/config/auth.yml" -}}
{{- $args = mergeOverwrite $args (fromYaml (include "vm.license.flag" .)) -}}
{{- $args = mergeOverwrite $args $app.extraArgs -}}
{{- toYaml (fromYaml (include "vm.args" $args)).args -}}
{{- end -}}
{{- define "vmselect.args" -}}
{{- $Values := (.helm).Values | default .Values -}}
{{- $app := $Values.vmselect -}}
{{- $args := default dict -}}
{{- $_ := set . "style" "plain" }}
{{- $_ := set . "appKey" "vmstorage" }}
{{- $_ := set $args "cacheDataPath" $app.cacheMountPath -}}
{{- $args = mergeOverwrite $args (fromYaml (include "vm.license.flag" .)) -}}
{{- $args = mergeOverwrite $args $app.extraArgs -}}
{{- $storage := $Values.vmstorage }}
{{- if and (not $app.suppressStorageFQDNsRender) $storage.enabled $storage.replicaCount }}
{{- $storageNodes := default list }}
{{- $fqdn := include "vm.fqdn" . }}
{{- if $Values.autoDiscovery }}
{{- if eq (include "vm.enterprise.disabled" . ) "true" }}
{{- fail "SRV autodiscovery is only supported in enterprise. Either define license or set `autoDiscovery` to `false`" }}
{{- end }}
{{- $storageNode := printf "srv+_vmselect._tcp.%s" $fqdn }}
{{- $storageNodes = append $storageNodes $storageNode }}
{{- else }}
{{- $port := "8401" }}
{{- range $i := until ($storage.replicaCount | int) -}}
{{- $_ := set $ "appIdx" $i }}
{{- $storageNode := include "vm.fqdn" $ -}}
{{- $storageNodes = append $storageNodes (printf "%s:%s" $storageNode $port) -}}
{{- end -}}
{{- $_ := unset . "appIdx" }}
{{- end }}
{{- $_ := set $args "storageNode" (concat ($args.storageNode | default list) $storageNodes) }}
{{- end }}
{{- $mode := $app.mode }}
{{- if and $mode (eq $mode "statefulSet") $app.enabled $app.replicaCount }}
{{- $selectNodes := default list }}
{{- $_ := set . "appKey" "vmselect" }}
{{- $fqdn := include "vm.fqdn" . }}
{{- $port := "8481" }}
{{- with $app.extraArgs.httpListenAddr }}
{{- $port = regexReplaceAll ".*:(\\d+)" . "${1}" }}
{{- end -}}
{{- range $i := until ($app.replicaCount | int) -}}
{{- $_ := set $ "appIdx" $i }}
{{- $selectNode := include "vm.fqdn" $ -}}
{{- $selectNodes = append $selectNodes (printf "%s:%s" $selectNode $port) -}}
{{- end -}}
{{- $_ := unset $ "appIdx" }}
{{- $_ := set $args "selectNode" (concat ($args.selectNode | default list) $selectNodes) }}
{{- end -}}
{{- if empty $args.storageNode }}
{{- fail "no storageNodes found. Either set vmstorage.enabled to true or add nodes to vmselect.extraArgs.storageNode"}}
{{- end }}
{{- $_ := unset . "style" }}
{{- $_ := unset . "appKey" }}
{{- toYaml (fromYaml (include "vm.args" $args)).args -}}
{{- end -}}
{{- define "vmstorage.args" -}}
{{- $Values := (.helm).Values | default .Values -}}
{{- $app := $Values.vmstorage -}}
{{- $args := default dict -}}
{{- $_ := set $args "retentionPeriod" (toString $app.retentionPeriod) -}}
{{- $_ := set $args "storageDataPath" $app.persistentVolume.mountPath -}}
{{- $args = mergeOverwrite $args (fromYaml (include "vm.license.flag" .)) -}}
{{- $args = mergeOverwrite $args $app.extraArgs -}}
{{- toYaml (fromYaml (include "vm.args" $args)).args -}}
{{- end -}}
{{- define "vmbackupmanager.args" -}}
{{- $Values := (.helm).Values | default .Values -}}
{{- $app := $Values.vmstorage -}}
{{- $manager := $app.vmbackupmanager -}}
{{- $args := default dict -}}
{{- $_ := set $args "disableHourly" $manager.disableHourly -}}
{{- $_ := set $args "disableDaily" $manager.disableDaily -}}
{{- $_ := set $args "disableWeekly" $manager.disableWeekly -}}
{{- $_ := set $args "disableMonthly" $manager.disableMonthly -}}
{{- $_ := set $args "keepLastHourly" $manager.retention.keepLastHourly -}}
{{- $_ := set $args "keepLastDaily" $manager.retention.keepLastDaily -}}
{{- $_ := set $args "keepLastWeekly" $manager.retention.keepLastWeekly -}}
{{- $_ := set $args "keepLastMonthly" $manager.retention.keepLastMonthly -}}
{{- $_ := set $args "storageDataPath" $app.persistentVolume.mountPath -}}
{{- $_ := set $args "dst" (printf "%s/$(POD_NAME)" $manager.destination) -}}
{{- $_ := set $args "snapshot.createURL" "http://localhost:8482/snapshot/create" -}}
{{- $_ := set $args "snapshot.deleteURL" "http://localhost:8482/snapshot/delete" -}}
{{- $args = mergeOverwrite $args (fromYaml (include "vm.license.flag" .)) -}}
{{- $args = mergeOverwrite $args $manager.extraArgs -}}
{{- toYaml (fromYaml (include "vm.args" $args)).args -}}
{{- end -}}
{{- define "vmbackupmanager.restore.args" -}}
{{- $Values := (.helm).Values | default .Values -}}
{{- $app := $Values.vmstorage -}}
{{- $manager := $app.vmbackupmanager -}}
{{- $args := default dict -}}
{{- $_ := set $args "storageDataPath" $app.persistentVolume.mountPath -}}
{{- $args = mergeOverwrite $args (fromYaml (include "vm.license.flag" .)) -}}
{{- $args = mergeOverwrite $args $manager.extraArgs -}}
{{- $output := (fromYaml (include "vm.args" $args)).args -}}
{{- $output = concat (list "restore") $output -}}
{{- toYaml $output -}}
{{- end -}}
{{- define "vmselect.ports" -}}
{{- $service := .service }}
{{- $extraArgs := .extraArgs -}}
- name: http
port: {{ $service.servicePort }}
protocol: TCP
targetPort: {{ $service.targetPort }}
{{- range $service.extraPorts }}
- name: {{ .name }}
port: {{ .port }}
protocol: TCP
targetPort: {{ .targetPort }}
{{- end }}
{{- with $extraArgs.clusternativeListenAddr }}
- name: cluster-tcp
protocol: TCP
port: {{ include "vm.port.from.flag" (dict "flag" .) }}
targetPort: cluster-tcp
{{- end }}
{{- end -}}
{{- define "vminsert.ports" -}}
{{- $service := .service }}
{{- $extraArgs := .extraArgs -}}
- name: http
port: {{ $service.servicePort }}
protocol: TCP
targetPort: {{ $service.targetPort }}
{{- range $service.extraPorts }}
- name: {{ .name }}
port: {{ .port }}
protocol: {{ .protocol | default "TCP" }}
targetPort: {{ .targetPort }}
{{- end }}
{{- with $extraArgs.clusternativeListenAddr }}
- name: cluster-tcp
protocol: TCP
port: {{ include "vm.port.from.flag" (dict "flag" .) }}
targetPort: cluster-tcp
{{- end }}
{{- with $extraArgs.graphiteListenAddr }}
- name: graphite-tcp
protocol: TCP
port: {{ include "vm.port.from.flag" (dict "flag" .) }}
targetPort: graphite-tcp
- name: graphite-udp
protocol: UDP
port: {{ include "vm.port.from.flag" (dict "flag" .) }}
targetPort: graphite-udp
{{- end }}
{{- with $extraArgs.influxListenAddr }}
- name: influx-tcp
protocol: TCP
port: {{ include "vm.port.from.flag" (dict "flag" .) }}
targetPort: influx-tcp
- name: influx-udp
protocol: UDP
port: {{ include "vm.port.from.flag" (dict "flag" .) }}
targetPort: influx-udp
{{- end }}
{{- with $extraArgs.opentsdbHTTPListenAddr }}
- name: opentsdbhttp
port: {{ include "vm.port.from.flag" (dict "flag" .) }}
targetPort: opentsdbhttp
{{- end }}
{{- with $extraArgs.opentsdbListenAddr }}
{{- if or $service.udp (ne $service.type "LoadBalancer") }}
- name: opentsdb-udp
protocol: UDP
port: {{ include "vm.port.from.flag" (dict "flag" .) }}
targetPort: opentsdb-udp
{{- end }}
- name: opentsdb-tcp
protocol: TCP
port: {{ include "vm.port.from.flag" (dict "flag" .) }}
targetPort: opentsdb-tcp
{{- end }}
{{- end -}}
{{- define "vmstorage.ports" -}}
{{- $service := .service -}}
- port: {{ $service.servicePort }}
targetPort: http
protocol: TCP
name: http
- port: {{ $service.vmselectPort }}
targetPort: vmselect
protocol: TCP
name: vmselect
- port: {{ $service.vminsertPort }}
targetPort: vminsert
protocol: TCP
name: vminsert
{{- range $service.extraPorts }}
- name: {{ .name }}
port: {{ .port }}
protocol: TCP
targetPort: {{ .targetPort }}
{{- end }}
{{- end -}}
{{- define "vmauth.ports" -}}
{{- $service := .service -}}
- port: {{ $service.servicePort }}
targetPort: http
protocol: TCP
name: http
{{- range $service.extraPorts }}
- name: {{ .name }}
port: {{ .port }}
protocol: TCP
targetPort: {{ .targetPort }}
{{- end }}
{{- end -}}
@@ -0,0 +1,4 @@
{{ range .Values.extraObjects }}
---
{{ tpl (ternary . (toYaml .) (typeIs "string" .)) $ }}
{{ end }}
@@ -0,0 +1,21 @@
{{- if .Values.extraSecrets }}
{{- $ctx := dict "helm" . }}
{{- range .Values.extraSecrets }}
---
apiVersion: v1
kind: Secret
metadata:
{{- with .annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
{{- $_ := set $ctx "extraLabels" .labels }}
labels: {{ include "vm.metaLabels" $ctx | nindent 4 }}
{{- $_ := unset $ctx "extraLabels" }}
name: {{ .name }}
namespace: {{ include "vm.namespace" $ }}
type: Opaque
{{- with .data }}
data: {{- tpl . $ | nindent 2 }}
{{- end }}
{{- end }}
{{- end }}
@@ -0,0 +1,28 @@
{{- $ctx := dict "helm" . }}
{{- range $name, $app := .Values }}
{{- if and (kindIs "map" $app) $app.enabled ($app.horizontalPodAutoscaler).enabled }}
{{- $isStatefulSet := or (eq $name "vmstorage") (eq $app.mode "statefulSet") }}
{{- $hpa := $app.horizontalPodAutoscaler }}
{{- $_ := set $ctx "extraLabels" $app.extraLabels }}
{{- $_ := set $ctx "appKey" $name }}
{{- $fullname := include "vm.plain.fullname" $ctx }}
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
labels: {{ include "vm.labels" $ctx | nindent 4 }}
name: {{ $fullname }}
namespace: {{ include "vm.namespace" $ }}
spec:
maxReplicas: {{ $hpa.maxReplicas }}
minReplicas: {{ $hpa.minReplicas }}
scaleTargetRef:
apiVersion: apps/v1
kind: {{ ternary "StatefulSet" "Deployment" $isStatefulSet }}
name: {{ $fullname }}
metrics: {{ toYaml $hpa.metrics | nindent 4 }}
{{- with $hpa.behavior }}
behavior: {{ toYaml . | nindent 4 }}
{{- end -}}
{{- end }}
{{- end }}
@@ -0,0 +1,43 @@
{{- $ctx := dict "helm" . }}
{{- range $name, $app := .Values }}
{{- if and (kindIs "map" $app) $app.enabled ($app.ingress).enabled }}
{{- $ingress := $app.ingress }}
{{- $_ := set $ctx "extraLabels" $ingress.extraLabels }}
{{- $_ := set $ctx "appKey" $name }}
{{- $fullname := include "vm.plain.fullname" $ctx }}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
{{- with $ingress.annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels: {{ include "vm.labels" $ctx | nindent 4 }}
name: {{ $fullname }}
namespace: {{ include "vm.namespace" $ }}
spec:
{{- with $ingress.ingressClassName }}
ingressClassName: {{ . }}
{{- end }}
{{- with $ingress.tls }}
tls: {{ toYaml . | nindent 4 }}
{{- end }}
rules:
{{- range $host := $app.ingress.hosts }}
{{- $paths := ternary (list $host.path) $host.path (kindIs "string" $host.path) }}
- host: {{ tpl $host.name $ | quote }}
http:
paths:
{{- range $path := $paths }}
- path: {{ $path }}
{{- with $app.ingress.pathType }}
pathType: {{ . }}
{{- end }}
backend:
service:
name: {{ $fullname }}
port: {{ include "vm.ingress.port" $host | nindent 18 }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
@@ -0,0 +1,51 @@
{{- $ctx := dict "helm" . }}
{{- range $name, $app := .Values }}
{{- if and (kindIs "map" $app) $app.enabled ($app.serviceMonitor).enabled }}
{{- $serviceMonitor := $app.serviceMonitor }}
{{- $_ := set $ctx "extraLabels" $serviceMonitor.extraLabels }}
{{- $_ := set $ctx "appKey" $name }}
{{ $fullname := include "vm.plain.fullname" $ctx }}
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
{{- with $serviceMonitor.annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels: {{ include "vm.labels" $ctx | nindent 4 }}
{{- $_ := unset $ctx "extraLabels" }}
name: {{ $fullname }}
{{- with $serviceMonitor.namespace }}
namespace: {{ . }}
{{- end }}
spec:
namespaceSelector:
matchNames:
- {{ include "vm.namespace" $ }}
selector:
matchLabels: {{ include "vm.selectorLabels" $ctx | nindent 6 }}
endpoints:
- port: http
{{- with $serviceMonitor.basicAuth }}
basicAuth: {{ toYaml . | nindent 8 }}
{{- end }}
{{- with $serviceMonitor.scheme }}
scheme: {{ . }}
{{- end }}
{{- with $serviceMonitor.interval }}
interval: {{ . }}
{{- end }}
{{- with $serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ . }}
{{- end }}
{{- with $serviceMonitor.tlsConfig }}
tlsConfig: {{ toYaml . | nindent 8 }}
{{- end }}
{{- with $serviceMonitor.relabelings }}
relabelings: {{ toYaml . | nindent 8 }}
{{- end }}
{{- with $serviceMonitor.metricRelabelings }}
metricRelabelings: {{ toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- end }}
@@ -0,0 +1,26 @@
{{- $ctx := dict "helm" . }}
{{- range $name, $app := .Values }}
{{- if and (kindIs "map" $app) $app.enabled ($app.podDisruptionBudget).enabled }}
{{- $pdb := $app.podDisruptionBudget }}
{{- $_ := set $ctx "extraLabels" $pdb.labels }}
{{- $_ := set $ctx "appKey" $name }}
{{- $fullname := include "vm.plain.fullname" $ctx }}
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: {{ $fullname }}
namespace: {{ include "vm.namespace" $ }}
labels: {{ include "vm.labels" $ctx | nindent 4 }}
{{- $_ := unset $ctx "extraLabels" }}
spec:
{{- with $pdb.minAvailable }}
minAvailable: {{ . }}
{{- end }}
{{- with $pdb.maxUnavailable }}
maxUnavailable: {{ . }}
{{- end }}
selector:
matchLabels: {{ include "vm.selectorLabels" $ctx | nindent 6 }}
{{- end }}
{{- end }}
@@ -0,0 +1,13 @@
{{- $app := .Values.vminsert }}
{{- if and $app.relabel.enabled (empty $app.relabel.configMap) }}
{{- $ctx := dict "helm" . "appKey" "vminsert" }}
{{- $ns := include "vm.namespace" $ctx }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "vminsert.relabel.config.name" $ctx }}
namespace: {{ $ns }}
labels: {{ include "vm.labels" $ctx | nindent 4 }}
data:
relabel.yml: |{{- toYaml $app.relabel.config | nindent 4 }}
{{- end }}
@@ -0,0 +1,43 @@
{{- $ctx := dict "helm" . }}
{{- range $name, $app := .Values }}
{{- if and (kindIs "map" $app) $app.enabled ($app.route).enabled }}
{{- $route := $app.route }}
{{- $_ := set $ctx "extraLabels" $route.extraLabels }}
{{- $_ := set $ctx "appKey" $name }}
{{- $fullname := include "vm.plain.fullname" $ctx }}
---
apiVersion: {{ $route.apiVersion | default "gateway.networking.k8s.io/v1" }}
kind: {{ $route.kind | default "HTTPRoute" }}
metadata:
name: {{ $fullname }}
namespace: {{ include "vm.namespace" $ }}
labels: {{ include "vm.labels" $ctx | nindent 4 }}
{{- with $route.annotations }}
annotations: {{ tpl (toYaml .) $ | nindent 4 }}
{{- end }}
spec:
{{- with $route.parentRefs }}
parentRefs: {{ toYaml . | nindent 4 }}
{{- end }}
{{- with $route.hostnames }}
hostnames: {{ tpl (toYaml .) $ | nindent 4 }}
{{- end }}
rules:
{{- with $route.extraRules }}
{{- tpl (toYaml .) $ | nindent 4 }}
{{- end }}
- backendRefs:
- name: {{ $fullname }}
port: {{ $route.port | default (include "vm.port.from.flag" (dict "flag" ($app.extraArgs).httpListenAddr)) }}
group: ''
kind: Service
weight: 1
{{- with $route.filters }}
filters: {{ toYaml . | nindent 8 }}
{{- end }}
{{- with $route.matches }}
matches: {{ tpl (toYaml .) $ | nindent 8 }}
{{- end }}
{{- end }}
{{- end }}
@@ -0,0 +1,23 @@
{{- $ctx := dict "helm" . }}
{{- $app := .Values.vmselect }}
{{- if and (kindIs "map" $app) $app.enabled ($app.service).enabled (default false $app.splitService) }}
{{- if ($app.externalService).enabled }}
{{- $service := $app.service }}
{{- $_ := set $ctx "extraLabels" $service.labels }}
{{- $_ := set $ctx "appKey" "vmselect" }}
{{- $fullname := include "vm.plain.fullname" $ctx }}
apiVersion: v1
kind: Service
metadata:
{{- with $service.annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels: {{ include "vm.labels" $ctx | nindent 4 }}
{{- $_ := unset $ctx "extraLabels" }}
name: {{ $app.externalService.name}}
namespace: {{ include "vm.namespace" $ }}
spec:
type: ExternalName
externalName: {{ $fullname }}.{{ include "vm.namespace" $ }}.svc.cluster.local
{{- end }}
{{- end }}
@@ -0,0 +1,121 @@
{{- /* VMSelect Split Services - only created when splitService is enabled */}}
{{- $ctx := dict "helm" . }}
{{- $app := .Values.vmselect }}
{{- if and (kindIs "map" $app) $app.enabled ($app.service).enabled (default false $app.splitService) }}
{{- $service := $app.service }}
{{- $_ := set $ctx "extraLabels" $service.labels }}
{{- $_ := set $ctx "appKey" "vmselect" }}
{{- $fullname := include "vm.plain.fullname" $ctx }}
---
# VMSelect HTTP-only Service
apiVersion: v1
kind: Service
metadata:
{{- with $service.annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels: {{ include "vm.labels" $ctx | nindent 4 }}
{{- $_ := unset $ctx "extraLabels" }}
name: {{ $fullname }}-http
namespace: {{ include "vm.namespace" $ }}
spec:
{{- $type := $service.type }}
{{- if and (not $type) (eq $app.mode "statefulSet") }}
{{- $type = "ClusterIP" }}
{{- end }}
type: {{ $type }}
{{- if eq $type "ClusterIP" }}
{{- with $service.clusterIP }}
clusterIP: {{ . }}
{{- end }}
{{- end }}
{{- with $service.externalIPs }}
externalIPs: {{ toYaml . | nindent 4 }}
{{- end }}
{{- with $service.loadBalancerIP }}
loadBalancerIP: {{ . }}
{{- end }}
{{- with $service.loadBalancerSourceRanges }}
loadBalancerSourceRanges: {{ toYaml . | nindent 4 }}
{{- end }}
{{- with $service.healthCheckNodePort }}
healthCheckNodePort: {{ . }}
{{- end }}
{{- with $service.externalTrafficPolicy }}
externalTrafficPolicy: {{ . }}
{{- end }}
{{- with $service.ipFamilyPolicy }}
ipFamilyPolicy: {{ . }}
{{- end }}
{{- with $service.ipFamilies }}
ipFamilies: {{ toYaml . | nindent 4 }}
{{- end }}
{{- with $service.trafficDistribution }}
trafficDistribution: {{ . }}
{{- end }}
ports:
- name: http
port: {{ $service.servicePort }}
protocol: TCP
targetPort: {{ $service.targetPort }}
selector: {{ include "vm.selectorLabels" $ctx | nindent 4 }}
{{- end }}
---
{{- /* VMSelect Clusternative-only Service - only created when splitService is enabled AND clusternativeListenAddr is set */}}
{{- if and (kindIs "map" $app) $app.enabled ($app.service).enabled (default false $app.splitService) $app.extraArgs.clusternativeListenAddr }}
{{- $service := $app.service }}
{{- $_ := set $ctx "extraLabels" $service.labels }}
{{- $_ := set $ctx "appKey" "vmselect" }}
{{- $fullname := include "vm.plain.fullname" $ctx }}
apiVersion: v1
kind: Service
metadata:
{{- with $service.annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels: {{ include "vm.labels" $ctx | nindent 4 }}
{{- $_ := unset $ctx "extraLabels" }}
name: {{ $fullname }}-cluster-tcp
namespace: {{ include "vm.namespace" $ }}
spec:
{{- $type := $service.type }}
{{- if and (not $type) (eq $app.mode "statefulSet") }}
{{- $type = "ClusterIP" }}
{{- end }}
type: {{ $type }}
{{- if eq $type "ClusterIP" }}
{{- with $service.clusterIP }}
clusterIP: {{ . }}
{{- end }}
{{- end }}
{{- with $service.externalIPs }}
externalIPs: {{ toYaml . | nindent 4 }}
{{- end }}
{{- with $service.loadBalancerIP }}
loadBalancerIP: {{ . }}
{{- end }}
{{- with $service.loadBalancerSourceRanges }}
loadBalancerSourceRanges: {{ toYaml . | nindent 4 }}
{{- end }}
{{- with $service.healthCheckNodePort }}
healthCheckNodePort: {{ . }}
{{- end }}
{{- with $service.externalTrafficPolicy }}
externalTrafficPolicy: {{ . }}
{{- end }}
{{- with $service.ipFamilyPolicy }}
ipFamilyPolicy: {{ . }}
{{- end }}
{{- with $service.ipFamilies }}
ipFamilies: {{ toYaml . | nindent 4 }}
{{- end }}
{{- with $service.trafficDistribution }}
trafficDistribution: {{ . }}
{{- end }}
ports:
- name: cluster-tcp
protocol: TCP
port: {{ include "vm.port.from.flag" (dict "flag" $app.extraArgs.clusternativeListenAddr) }}
targetPort: cluster-tcp
selector: {{ include "vm.selectorLabels" $ctx | nindent 4 }}
{{- end }}
@@ -0,0 +1,60 @@
{{- $ctx := dict "helm" . }}
{{- range $name, $app := .Values }}
{{- if and (kindIs "map" $app) $app.enabled ($app.service).enabled }}
{{- $service := $app.service }}
{{- $_ := set $ctx "extraLabels" $service.labels }}
{{- $_ := set $ctx "appKey" $name }}
{{- $fullname := include "vm.plain.fullname" $ctx }}
---
apiVersion: v1
kind: Service
metadata:
{{- with $service.annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
labels: {{ include "vm.labels" $ctx | nindent 4 }}
{{- $_ := unset $ctx "extraLabels" }}
name: {{ $fullname }}
namespace: {{ include "vm.namespace" $ }}
spec:
{{- $type := $service.type }}
{{- if and (not $type) (eq $app.mode "statefulSet") }}
{{- $type = "ClusterIP" }}
{{- end }}
type: {{ $type }}
{{- if eq $type "ClusterIP" }}
{{- with $service.clusterIP }}
clusterIP: {{. }}
{{- end }}
{{- end }}
{{- with $service.externalIPs }}
externalIPs: {{ toYaml . | nindent 4 }}
{{- end }}
{{- with $service.loadBalancerIP }}
loadBalancerIP: {{ . }}
{{- end }}
{{- with $service.loadBalancerSourceRanges }}
loadBalancerSourceRanges: {{ toYaml . | nindent 4 }}
{{- end }}
{{- with $service.healthCheckNodePort }}
healthCheckNodePort: {{ . }}
{{- end }}
{{- with $service.externalTrafficPolicy }}
externalTrafficPolicy: {{ . }}
{{- end }}
{{- with $service.ipFamilyPolicy }}
ipFamilyPolicy: {{ . }}
{{- end }}
{{- with $service.ipFamilies }}
ipFamilies: {{ toYaml . | nindent 4 }}
{{- end }}
{{- with $service.trafficDistribution }}
trafficDistribution: {{ . }}
{{- end }}
{{- $portsTpl := printf "%s.ports" $name }}
{{- with include $portsTpl $app }}
ports: {{ . | nindent 4 }}
{{- end }}
selector: {{ include "vm.selectorLabels" $ctx | nindent 4 }}
{{- end }}
{{- end }}
@@ -0,0 +1,17 @@
{{- $sa := .Values.serviceAccount }}
{{- if $sa.create }}
{{- $ctx := dict "helm" . }}
{{- $fullname := include "vm.plain.fullname" $ctx }}
{{- $ns := include "vm.namespace" $ctx }}
apiVersion: v1
kind: ServiceAccount
metadata:
{{- $_ := set $ctx "extraLabels" $sa.extraLabels }}
labels: {{ include "vm.metaLabels" $ctx | nindent 4 }}
{{- $_ := unset $ctx "extraLabels" }}
{{- with $sa.annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
name: {{ tpl ((.Values.serviceAccount).name | default $fullname) $ctx }}
namespace: {{ $ns }}
{{- end }}
@@ -0,0 +1,36 @@
{{- if and (empty .Values.vmauth.configSecretName) .Values.vmauth.enabled }}
{{- $ctx := dict "helm" . "appKey" "vmauth" "style" "plain" }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "vm.plain.fullname" $ctx }}
namespace: {{ include "vm.namespace" $ctx }}
labels: {{ include "vm.labels" $ctx | nindent 4 }}
type: Opaque
data:
{{- $config := .Values.vmauth.config }}
{{- $_ := set $ctx "appKey" "vminsert" -}}
{{- $writeURL := urlParse (include "vm.url" $ctx) -}}
{{- $_ := set $writeURL "path" (printf "%s/insert" $writeURL.path) -}}
{{- $_ := set $ctx "appKey" "vmselect" -}}
{{- $readURL := urlParse (include "vm.url" $ctx) -}}
{{- $_ := set $readURL "path" (printf "%s/select" $readURL.path) -}}
{{- $_ := set . "vm" (dict "read" $readURL "write" $writeURL) -}}
{{- if or (empty $config) $config.unauthorized_user }}
{{- $urlMap := ($config.unauthorized_user).url_map | default list }}
{{- if empty $urlMap }}
{{- if $.Values.vmselect.service.enabled }}
{{- $readPaths := list (printf "%s/*" $readURL.path) }}
{{- $readPrefix := urlJoin (omit .vm.read "path") }}
{{- $urlMap = append $urlMap (dict "src_paths" $readPaths "url_prefix" (quote $readPrefix) "discover_backend_ips" true) }}
{{- end }}
{{- if $.Values.vminsert.service.enabled }}
{{- $writePaths := list (printf "%s/*" $writeURL.path) }}
{{- $writePrefix := urlJoin (omit .vm.write "path") }}
{{- $urlMap = append $urlMap (dict "src_paths" $writePaths "url_prefix" (quote $writePrefix) "discover_backend_ips" true) }}
{{- end }}
{{- $_ := set $config "unauthorized_user" (dict "url_map" $urlMap) }}
{{- end }}
{{- end }}
auth.yml: |{{- tpl (toYaml $config) . | b64enc | nindent 4 }}
{{- end }}
@@ -0,0 +1,125 @@
{{- $app := merge (deepCopy .Values.vmauth) (deepCopy .Values.common) -}}
{{- $_ := set .Values "vmauth" $app }}
{{- if $app.enabled -}}
{{- $ctx := dict "helm" . "appKey" "vmauth" }}
{{- $fullname := include "vm.plain.fullname" $ctx }}
{{- $sa := include "vm.fullname" . }}
{{- $ns := include "vm.namespace" $ctx }}
apiVersion: apps/v1
kind: Deployment
metadata:
{{- with $app.annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
{{- $_ := set $ctx "extraLabels" $app.extraLabels }}
labels: {{ include "vm.labels" $ctx | nindent 4 }}
{{- $_ := unset $ctx "extraLabels" }}
name: {{ $fullname }}
namespace: {{ $ns }}
spec:
selector:
matchLabels: {{ include "vm.selectorLabels" $ctx | nindent 6 }}
{{- if not $app.horizontalPodAutoscaler.enabled }}
replicas: {{ $app.replicaCount }}
{{- end }}
{{- with $app.strategy }}
strategy: {{ toYaml . | nindent 4 }}
{{- end }}
template:
metadata:
{{- with $app.podAnnotations }}
annotations: {{ toYaml . | nindent 8 }}
{{- end }}
{{- $_ := set $ctx "extraLabels" $app.podLabels }}
labels: {{ include "vm.podLabels" $ctx | nindent 8 }}
{{- $_ := unset $ctx "extraLabels" }}
spec:
{{- with $app.priorityClassName }}
priorityClassName: {{ . }}
{{- end }}
{{- if or (.Values.serviceAccount).name (.Values.serviceAccount).create }}
serviceAccountName: {{ tpl ((.Values.serviceAccount).name | default $sa) $ctx }}
automountServiceAccountToken: {{ .Values.serviceAccount.automountToken }}
{{- end }}
{{- with $app.initContainers }}
initContainers: {{ toYaml . | nindent 8 }}
{{- end }}
{{- with ($app.imagePullSecrets | default .Values.global.imagePullSecrets) }}
imagePullSecrets: {{ toYaml . | nindent 8 }}
{{- end }}
containers:
- name: vmauth
image: {{ include "vm.image" $ctx }}
imagePullPolicy: {{ $app.image.pullPolicy }}
{{- with $app.lifecycle }}
lifecycle: {{ . | toYaml | nindent 12 }}
{{- end }}
{{- with $app.containerWorkingDir }}
workingDir: {{ . }}
{{- end }}
{{- if $app.securityContext.enabled }}
securityContext: {{ include "vm.securityContext" (dict "securityContext" $app.securityContext "helm" .) | nindent 12 }}
{{- end }}
args: {{ include "vmauth.args" $ctx | nindent 12 }}
{{- with $app.envFrom }}
envFrom: {{ toYaml . | nindent 12 }}
{{- end }}
{{- with $app.env }}
env: {{ toYaml . | nindent 12 }}
{{- end }}
ports:
- name: {{ $app.ports.name | default "http" }}
containerPort: {{ include "vm.port.from.flag" (dict "flag" $app.extraArgs.httpListenAddr "default" "8427") }}
{{- with (fromYaml (include "vm.probe" (dict "app" $app "type" "readiness"))) }}
readinessProbe: {{ toYaml . | nindent 12 }}
{{- end }}
{{- with (fromYaml (include "vm.probe" (dict "app" $app "type" "liveness"))) }}
livenessProbe: {{ toYaml . | nindent 12 }}
{{- end }}
{{- with (fromYaml (include "vm.probe" (dict "app" $app "type" "startup"))) }}
startupProbe: {{ toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- name: config
mountPath: /config
{{- with $app.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- include "vm.license.mount" . | nindent 12 }}
{{- with $app.resources }}
resources: {{ toYaml . | nindent 12 }}
{{- end }}
{{- with $app.extraContainers }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $app.nodeSelector }}
nodeSelector: {{ toYaml . | nindent 8 }}
{{- end }}
{{- if $app.podSecurityContext.enabled }}
securityContext: {{ include "vm.securityContext" (dict "securityContext" $app.podSecurityContext "helm" .) | nindent 8 }}
{{- end }}
{{- with $app.tolerations }}
tolerations: {{ toYaml . | nindent 8 }}
{{- end }}
{{- with $app.affinity }}
affinity: {{ toYaml . | nindent 8 }}
{{- end }}
{{- with $app.topologySpreadConstraints }}
topologySpreadConstraints:
{{- range $constraint := . }}
- {{ toYaml $constraint | nindent 10 | trim }}
{{- if not $constraint.labelSelector }}
labelSelector:
matchLabels: {{ include "vm.selectorLabels" $ctx | nindent 14 }}
{{- end }}
{{- end }}
{{- end }}
volumes:
- name: config
secret:
secretName: {{ ternary $fullname (tpl $app.configSecretName $ctx) (empty $app.configSecretName) }}
{{- with $app.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "vm.license.volume" . | nindent 8 }}
{{- end }}
@@ -0,0 +1,168 @@
{{- $app := merge (deepCopy .Values.vminsert) (deepCopy .Values.common) -}}
{{- $_ := set .Values "vminsert" $app }}
{{- if $app.enabled -}}
{{- $ctx := dict "helm" . "appKey" "vminsert" }}
{{- $fullname := include "vm.plain.fullname" $ctx }}
{{- $relabelConfig := include "vminsert.relabel.config.name" $ctx }}
{{- $sa := include "vm.fullname" . }}
{{- $ns := include "vm.namespace" $ctx }}
apiVersion: apps/v1
kind: Deployment
metadata:
{{- with $app.annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
{{- $_ := set $ctx "extraLabels" $app.extraLabels }}
labels: {{ include "vm.labels" $ctx | nindent 4 }}
{{- $_ := unset $ctx "extraLabels" }}
name: {{ $fullname }}
namespace: {{ $ns }}
spec:
selector:
matchLabels: {{ include "vm.selectorLabels" $ctx | nindent 6 }}
{{- if not $app.horizontalPodAutoscaler.enabled }}
replicas: {{ $app.replicaCount }}
{{- end }}
{{- with $app.strategy }}
strategy: {{ toYaml . | nindent 4 }}
{{- end }}
template:
metadata:
{{- with $app.podAnnotations }}
annotations: {{ toYaml . | nindent 8 }}
{{- end }}
{{- $_ := set $ctx "extraLabels" $app.podLabels }}
labels: {{ include "vm.podLabels" $ctx | nindent 8 }}
spec:
{{- with $app.priorityClassName }}
priorityClassName: {{ . }}
{{- end }}
{{- with $app.initContainers }}
initContainers: {{ toYaml . | nindent 8 }}
{{- end }}
{{- with ($app.imagePullSecrets | default .Values.global.imagePullSecrets) }}
imagePullSecrets: {{ toYaml . | nindent 8 }}
{{- end }}
containers:
- name: vminsert
image: {{ include "vm.image" $ctx }}
imagePullPolicy: {{ $app.image.pullPolicy }}
{{- with $app.lifecycle }}
lifecycle: {{ . | toYaml | nindent 12 }}
{{- end }}
{{- with $app.containerWorkingDir }}
workingDir: {{ . }}
{{- end }}
{{- if $app.securityContext.enabled }}
securityContext: {{ include "vm.securityContext" (dict "securityContext" $app.securityContext "helm" .) | nindent 12 }}
{{- end }}
args: {{ include "vminsert.args" $ctx | nindent 12 }}
{{- with $app.envFrom }}
envFrom: {{ toYaml . | nindent 12 }}
{{- end }}
{{- with $app.env }}
env: {{ toYaml . | nindent 12 }}
{{- end }}
ports:
- name: {{ $app.ports.name | default "http" }}
containerPort: {{ include "vm.port.from.flag" (dict "flag" $app.extraArgs.httpListenAddr "default" "8480") }}
{{- with $app.extraArgs.clusternativeListenAddr }}
- name: cluster-tcp
protocol: TCP
containerPort: {{ include "vm.port.from.flag" (dict "flag" .) }}
{{- end }}
{{- with $app.extraArgs.graphiteListenAddr }}
- name: graphite-tcp
protocol: TCP
containerPort: {{ include "vm.port.from.flag" (dict "flag" .) }}
- name: graphite-udp
protocol: UDP
containerPort: {{ include "vm.port.from.flag" (dict "flag" .) }}
{{- end }}
{{- with $app.extraArgs.influxListenAddr }}
- name: influx-tcp
protocol: TCP
containerPort: {{ include "vm.port.from.flag" (dict "flag" .) }}
- name: influx-udp
protocol: UDP
containerPort: {{ include "vm.port.from.flag" (dict "flag" .) }}
{{- end }}
{{- with $app.extraArgs.opentsdbHTTPListenAddr }}
- name: opentsdbhttp
protocol: TCP
containerPort: {{ include "vm.port.from.flag" (dict "flag" .) }}
{{- end }}
{{- with $app.extraArgs.opentsdbListenAddr }}
- name: opentsdb-tcp
protocol: TCP
containerPort: {{ include "vm.port.from.flag" (dict "flag" .) }}
- name: opentsdb-udp
protocol: UDP
containerPort: {{ include "vm.port.from.flag" (dict "flag" .) }}
{{- end }}
{{- with (fromYaml (include "vm.probe" (dict "app" $app "type" "readiness"))) }}
readinessProbe: {{ toYaml . | nindent 12 }}
{{- end }}
{{- with (fromYaml (include "vm.probe" (dict "app" $app "type" "liveness"))) }}
livenessProbe: {{ toYaml . | nindent 12 }}
{{- end }}
{{- with (fromYaml (include "vm.probe" (dict "app" $app "type" "startup"))) }}
startupProbe: {{ toYaml . | nindent 12 }}
{{- end }}
{{- if or $app.extraVolumeMounts (include "vm.license.mount" .) $app.relabel.enabled }}
volumeMounts:
{{- if $app.relabel.enabled }}
- name: relabelconfig
mountPath: /relabelconfig
{{- end }}
{{- with $app.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- include "vm.license.mount" . | nindent 12 }}
{{- end }}
{{- with $app.resources }}
resources: {{ toYaml . | nindent 12 }}
{{- end }}
{{- with $app.extraContainers }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $app.nodeSelector }}
nodeSelector: {{ toYaml . | nindent 8 }}
{{- end }}
{{- if $app.podSecurityContext.enabled }}
securityContext: {{ include "vm.securityContext" (dict "securityContext" $app.podSecurityContext "helm" .) | nindent 8 }}
{{- end }}
{{- if or (.Values.serviceAccount).name (.Values.serviceAccount).create }}
serviceAccountName: {{ tpl ((.Values.serviceAccount).name | default $sa) $ctx }}
automountServiceAccountToken: {{ .Values.serviceAccount.automountToken }}
{{- end }}
{{- with $app.tolerations }}
tolerations: {{ toYaml . | nindent 8 }}
{{- end }}
{{- with $app.affinity }}
affinity: {{ toYaml . | nindent 8 }}
{{- end }}
{{- with $app.topologySpreadConstraints }}
topologySpreadConstraints:
{{- range $constraint := . }}
- {{ toYaml $constraint | nindent 10 | trim }}
{{- if not $constraint.labelSelector }}
labelSelector:
matchLabels: {{ include "vm.selectorLabels" $ctx | nindent 14 }}
{{- end }}
{{- end }}
{{- end }}
terminationGracePeriodSeconds: {{ $app.terminationGracePeriodSeconds }}
{{- if or (and (include "vm.license.secret.key" .) (include "vm.license.secret.name" .)) $app.extraVolumes $app.relabel.enabled }}
volumes:
{{- if $app.relabel.enabled }}
- name: relabelconfig
configMap:
name: {{ $relabelConfig }}
{{- end }}
{{- with $app.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "vm.license.volume" . | nindent 8 }}
{{- end }}
{{- end }}
@@ -0,0 +1,37 @@
{{- if .Values.vmselect.enabled }}
{{- if .Values.vmselect.clusternativeService.enabled }}
{{- $ctx := dict "helm" . "appKey" "vmselect" }}
{{- $fullname := include "vm.plain.fullname" $ctx }}
apiVersion: v1
kind: Service
metadata:
name: {{ $fullname }}-tcp-lb
namespace: {{ .Release.Namespace }}
annotations:
networking.gke.io/load-balancer-type: "Internal"
labels: {{ include "vm.labels" $ctx | nindent 4 }}
{{- if .Values.vmselect.service.labels }}
{{ toYaml .Values.vmselect.service.labels | indent 4}}
{{- end }}
spec:
type: LoadBalancer
{{- if .Values.vmselect.clusternativeService.sessionAffinity }}
sessionAffinity: {{ .Values.vmselect.clusternativeService.sessionAffinity }}
{{- end }}
{{- if .Values.vmselect.clusternativeService.sessionAffinityConfig }}
sessionAffinityConfig: {{- include "common.tplvalues.render" (dict "value" .Values.vmselect.clusternativeService.sessionAffinityConfig "context" $) | nindent 4 }}
{{- end }}
{{- if .Values.vmselect.clusternativeService.ipFamilyPolicy }}
ipFamilyPolicy: {{ .Values.vmselect.clusternativeService.ipFamilyPolicy }}
{{- end }}
ports:
{{- if .Values.vmselect.extraArgs.clusternativeListenAddr }}
- name: cluster-tcp
port: {{ .Values.vmselect.clusternativeService.port }}
protocol: TCP
targetPort: cluster-tcp
{{- end }}
selector: {{ include "vm.selectorLabels" $ctx | nindent 4 }}
{{- end }}
{{- end }}
@@ -0,0 +1,208 @@
{{- $storageName := "cache-volume" }}
{{- $app := merge (deepCopy .Values.vmselect) (deepCopy .Values.common) -}}
{{- $pvc := $app.persistentVolume }}
{{- $_ := set .Values "vmselect" $app }}
{{- $mode := $app.mode }}
{{- if and $mode $app.enabled (hasKey $app $mode) -}}
{{- $modeOpts := index $app $mode }}
{{- $ctx := dict "helm" . "appKey" "vmselect" }}
{{- $fullname := include "vm.plain.fullname" $ctx }}
{{- $sa := include "vm.fullname" . }}
{{- $ns := include "vm.namespace" $ctx }}
apiVersion: apps/v1
kind: {{ title $mode }}
metadata:
name: {{ $fullname }}
namespace: {{ $ns }}
{{- $_ := set $ctx "extraLabels" $app.extraLabels }}
labels: {{ include "vm.labels" $ctx | nindent 4 }}
{{- $_ := unset $ctx "extraLabels" }}
{{- with $app.annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
spec:
{{- with $modeOpts.spec }}
{{- toYaml . | nindent 2 }}
{{- end }}
{{- if not $app.horizontalPodAutoscaler.enabled }}
replicas: {{ $app.replicaCount }}
{{- end }}
{{- if eq $mode "statefulSet" }}
serviceName: {{ $fullname }}
{{- end }}
selector:
matchLabels: {{ include "vm.selectorLabels" $ctx | nindent 6 }}
template:
metadata:
{{- $_ := set $ctx "extraLabels" $app.podLabels }}
labels: {{ include "vm.podLabels" $ctx | nindent 8 }}
{{- $_ := unset $ctx "extraLabels" }}
{{- with $app.podAnnotations }}
annotations: {{ toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with $app.priorityClassName }}
priorityClassName: {{ . }}
{{- end }}
{{- with $app.schedulerName }}
schedulerName: {{ . }}
{{- end }}
{{- if or (.Values.serviceAccount).name (.Values.serviceAccount).create }}
serviceAccountName: {{ tpl ((.Values.serviceAccount).name | default $sa) $ctx }}
automountServiceAccountToken: {{ .Values.serviceAccount.automountToken }}
{{- end }}
{{- if $app.podSecurityContext.enabled }}
securityContext: {{ include "vm.securityContext" (dict "securityContext" $app.podSecurityContext "helm" .) | nindent 8 }}
{{- end }}
{{- with $app.initContainers }}
initContainers: {{ toYaml . | nindent 8 }}
{{- end }}
{{- with ($app.imagePullSecrets | default .Values.global.imagePullSecrets) }}
imagePullSecrets: {{ toYaml . | nindent 8 }}
{{- end }}
containers:
- name: vmselect
{{- if $app.securityContext.enabled }}
securityContext: {{ include "vm.securityContext" (dict "securityContext" $app.securityContext "helm" .) | nindent 12 }}
{{- end }}
image: {{ include "vm.image" $ctx }}
imagePullPolicy: {{ $app.image.pullPolicy }}
{{- with $app.lifecycle }}
lifecycle: {{ . | toYaml | nindent 12 }}
{{- end }}
{{- with $app.containerWorkingDir }}
workingDir: {{ . }}
{{- end }}
args: {{ include "vmselect.args" $ctx | nindent 12 }}
{{- with $app.envFrom }}
envFrom: {{ toYaml . | nindent 12 }}
{{- end }}
{{- with $app.env }}
env: {{ toYaml . | nindent 12 }}
{{- end }}
ports:
- name: {{ $app.ports.name | default "http" }}
containerPort: {{ include "vm.port.from.flag" (dict "flag" $app.extraArgs.httpListenAddr "default" "8481") }}
{{- with $app.extraArgs.clusternativeListenAddr }}
- name: cluster-tcp
protocol: TCP
containerPort: {{ include "vm.port.from.flag" (dict "flag" .) }}
{{- end }}
{{- with (fromYaml (include "vm.probe" (dict "app" $app "type" "readiness"))) }}
readinessProbe: {{ toYaml . | nindent 12 }}
{{- end }}
{{- with (fromYaml (include "vm.probe" (dict "app" $app "type" "liveness"))) }}
livenessProbe: {{ toYaml . | nindent 12 }}
{{- end }}
{{- with (fromYaml (include "vm.probe" (dict "app" $app "type" "startup"))) }}
startupProbe: {{ toYaml . | nindent 12 }}
{{- end }}
{{- with $app.resources }}
resources: {{ toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- mountPath: {{ $app.cacheMountPath }}
name: {{ $storageName }}
{{- range $app.extraHostPathMounts }}
- name: {{ tpl .name $ctx }}
mountPath: {{ .mountPath }}
{{- with .subPath }}
subPath: {{ . }}
{{- end }}
{{- with .readOnly }}
readOnly: {{ . }}
{{- end }}
{{- end }}
{{- with $app.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- include "vm.license.mount" . | nindent 12 }}
{{- with $app.extraContainers }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $app.nodeSelector }}
nodeSelector: {{ toYaml . | nindent 8 }}
{{- end }}
{{- with $app.tolerations }}
tolerations: {{ toYaml . | nindent 8 }}
{{- end }}
{{- with $app.topologySpreadConstraints }}
topologySpreadConstraints:
{{- range $constraint := . }}
- {{ toYaml $constraint | nindent 10 | trim }}
{{- if not $constraint.labelSelector }}
labelSelector:
matchLabels: {{ include "vm.selectorLabels" $ctx | nindent 14 }}
{{- end }}
{{- end }}
{{- end }}
{{- with $app.affinity }}
affinity: {{ toYaml . | nindent 8 }}
{{- end }}
terminationGracePeriodSeconds: {{ $app.terminationGracePeriodSeconds }}
volumes:
{{- with $app.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if or (eq $mode "deployment") (not $pvc.enabled) $pvc.existingClaim }}
- name: {{ $storageName }}
{{- if or (and (eq $mode "deployment") $pvc.enabled) $pvc.existingClaim }}
persistentVolumeClaim:
claimName: {{ $pvc.existingClaim | default $fullname }}
{{- else }}
emptyDir: {{ toYaml $app.emptyDir | nindent 12 }}
{{- end }}
{{- end }}
{{- include "vm.license.volume" . | nindent 8 }}
{{- if and (eq $mode "statefulSet") $pvc.enabled (not $pvc.existingClaim) }}
volumeClaimTemplates:
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ tpl $pvc.name $ctx | default $storageName }}
{{- with $pvc.annotations }}
annotations: {{ toYaml . | nindent 10 }}
{{- end }}
{{- with $pvc.extraLabels }}
labels: {{ toYaml . | nindent 10 }}
{{- end }}
spec:
{{- with $pvc.accessModes }}
accessModes: {{ toYaml . | nindent 10 }}
{{- end }}
resources:
requests:
storage: {{ $pvc.size }}
{{- with $pvc.storageClassName }}
storageClassName: {{ ternary "" . (eq "-" .) }}
{{- end }}
{{- end }}
{{- if and $pvc.enabled (not $pvc.existingClaim) (eq $app.mode "deployment") }}
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ tpl $pvc.name $ctx | default $fullname }}
namespace: {{ $ns }}
{{- $_ := set $ctx "extraLabels" $pvc.extraLabels }}
labels: {{ include "vm.labels" $ctx | nindent 4 }}
{{- $_ := unset $ctx "extraLabels" }}
{{- with $pvc.annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
spec:
{{- with $pvc.accessModes }}
accessModes: {{ toYaml . | nindent 4 }}
{{- end }}
resources:
requests:
storage: {{ $pvc.size }}
{{- with $pvc.storageClassName }}
storageClassName: {{ . }}
{{- end }}
{{- with $pvc.matchLabels }}
selector:
matchLabels: {{ toYaml . | nindent 6 }}
{{- end }}
{{- end }}
{{- end }}
@@ -0,0 +1,289 @@
{{- $app := merge (deepCopy .Values.vmstorage) (deepCopy .Values.common) -}}
{{- $pvc := $app.persistentVolume }}
{{- $_ := set .Values "vmstorage" $app }}
{{- if $app.enabled -}}
{{- $ctx := dict "helm" . "appKey" "vmstorage" }}
{{- $fullname := include "vm.plain.fullname" $ctx }}
{{- $sa := include "vm.fullname" . }}
{{- $ns := include "vm.namespace" $ctx }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
{{- with $app.annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end }}
{{- $_ := set $ctx "extraLabels" $app.extraLabels }}
labels: {{ include "vm.labels" $ctx | nindent 4 }}
{{- $_ := unset $ctx "extraLabels" }}
name: {{ $fullname }}
namespace: {{ $ns }}
spec:
serviceName: {{ $fullname }}
selector:
matchLabels: {{ include "vm.selectorLabels" $ctx | nindent 6 }}
replicas: {{ $app.replicaCount }}
podManagementPolicy: {{ $app.podManagementPolicy }}
template:
metadata:
{{- with $app.podAnnotations }}
annotations: {{ toYaml . | nindent 8 }}
{{- end }}
{{- $_ := set $ctx "extraLabels" $app.podLabels }}
labels: {{ include "vm.podLabels" $ctx | nindent 8 }}
spec:
{{- with $app.priorityClassName }}
priorityClassName: {{ . }}
{{- end }}
{{- with $app.schedulerName }}
schedulerName: {{ . }}
{{- end }}
{{- $manager := $app.vmbackupmanager }}
{{- if or $app.initContainers $manager.restore.onStart.enabled }}
initContainers:
{{- with $app.initContainers -}}
{{- toYaml . | nindent 8 }}
{{- end -}}
{{- if $manager.restore.onStart.enabled }}
{{- include "vm.enterprise.only" . }}
- name: vmbackupmanager-restore
{{- $_ := set $ctx "appKey" (list "vmstorage" "vmbackupmanager") }}
image: {{ include "vm.image" $ctx }}
imagePullPolicy: {{ $app.image.pullPolicy }}
{{- if $app.securityContext.enabled }}
securityContext: {{ include "vm.securityContext" (dict "securityContext" $app.securityContext "helm" .) | nindent 12 }}
{{- end }}
args: {{ include "vmbackupmanager.restore.args" $ctx | nindent 12 }}
{{- with $manager.resources }}
resources: {{ toYaml . | nindent 12 }}
{{- end }}
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
{{- with $manager.env }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: manager-http
containerPort: 8300
volumeMounts:
- name: vmstorage-volume
mountPath: {{ $pvc.mountPath }}
subPath: {{ $pvc.subPath }}
{{- range $manager.extraSecretMounts }}
- name: {{ tpl .name $ctx }}
mountPath: {{ .mountPath }}
subPath: {{ .subPath }}
{{- end }}
{{- end }}
{{- end }}
{{- with ($app.imagePullSecrets | default .Values.global.imagePullSecrets) }}
imagePullSecrets: {{ toYaml . | nindent 8 }}
{{- end }}
containers:
- name: vmstorage
{{- $_ := set $ctx "appKey" "vmstorage" }}
image: {{ include "vm.image" $ctx }}
imagePullPolicy: {{ $app.image.pullPolicy }}
{{- with $app.containerWorkingDir }}
workingDir: {{ . }}
{{- end }}
{{- if $app.securityContext.enabled }}
securityContext: {{ include "vm.securityContext" (dict "securityContext" $app.securityContext "helm" .) | nindent 12 }}
{{- end }}
{{- with $app.lifecycle }}
lifecycle: {{ . | toYaml | nindent 12 }}
{{- end }}
args: {{ include "vmstorage.args" $ctx | nindent 12 }}
ports:
- name: {{ $app.ports.name | default "http" }}
containerPort: {{ include "vm.port.from.flag" (dict "flag" $app.extraArgs.httpListenAddr "default" "8482") }}
- name: vminsert
containerPort: 8400
- name: vmselect
containerPort: 8401
{{- with $app.envFrom }}
envFrom: {{ toYaml . | nindent 12 }}
{{- end }}
{{- with $app.env }}
env: {{ toYaml . | nindent 12 }}
{{- end }}
{{- with (fromYaml (include "vm.probe" (dict "app" $app "type" "readiness"))) }}
readinessProbe: {{ toYaml . | nindent 12 }}
{{- end }}
{{- with (fromYaml (include "vm.probe" (dict "app" $app "type" "liveness"))) }}
livenessProbe: {{ toYaml . | nindent 12 }}
{{- end }}
{{- with (fromYaml (include "vm.probe" (dict "app" $app "type" "startup"))) }}
startupProbe: {{ toYaml . | nindent 12 }}
{{- end }}
{{- with $app.resources }}
resources: {{ toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
{{- with $pvc }}
- name: {{ tpl .name $ctx }}
mountPath: {{ .mountPath }}
{{- with .subPath }}
subPath: {{ . }}
{{- end }}
{{- end }}
{{- range $app.extraHostPathMounts }}
- name: {{ tpl .name $ctx }}
mountPath: {{ .mountPath }}
{{- with .subPath }}
subPath: {{ . }}
{{- end }}
{{- with .readOnly }}
readOnly: {{ . }}
{{- end }}
{{- end }}
{{- range $app.extraConfigmapMounts }}
- name: {{ $app.name }}-{{ .name }}
mountPath: {{ .mountPath }}
{{- with .subPath }}
subPath: {{ . }}
{{- end }}
{{- with .readOnly }}
readOnly: {{ . }}
{{- end }}
{{- end }}
{{- range $app.extraSecretMounts }}
- name: {{ .name }}
mountPath: {{ .mountPath }}
{{- with .subPath }}
subPath: {{ . }}
{{- end }}
{{- with .readOnly }}
readOnly: {{ . }}
{{- end }}
{{- end }}
{{- with $app.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- include "vm.license.mount" . | nindent 12 }}
{{- if $manager.enabled }}
{{- include "vm.enterprise.only" . }}
- name: vmbackupmanager
{{- $_ := set $ctx "appKey" (list "vmstorage" "vmbackupmanager") }}
image: {{ include "vm.image" $ctx }}
imagePullPolicy: {{ $app.image.pullPolicy }}
{{- if $app.securityContext.enabled }}
securityContext: {{ include "vm.securityContext" (dict "securityContext" $app.securityContext "helm" .) | nindent 12 }}
{{- end }}
args: {{ include "vmbackupmanager.args" $ctx | nindent 12 }}
{{- with $manager.resources }}
resources: {{ toYaml . | nindent 12 }}
{{- end }}
{{- with (fromYaml (include "vm.probe" (dict "app" $manager "type" "readiness"))) }}
readinessProbe: {{ toYaml . | nindent 12 }}
{{- end }}
{{- with (fromYaml (include "vm.probe" (dict "app" $manager "type" "liveness"))) }}
livenessProbe: {{ toYaml . | nindent 12 }}
{{- end }}
{{- with (fromYaml (include "vm.probe" (dict "app" $manager "type" "startup"))) }}
startupProbe: {{ toYaml . | nindent 12 }}
{{- end }}
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
{{- with $manager.env }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: manager-http
containerPort: 8300
volumeMounts:
{{- with $pvc }}
- name: {{ tpl .name $ctx }}
mountPath: {{ .mountPath }}
{{- with .subPath }}
subPath: {{ . }}
{{- end }}
{{- end }}
{{- range $manager.extraSecretMounts }}
- name: {{ tpl .name $ctx }}
mountPath: {{ .mountPath }}
{{- with .subPath }}
subPath: {{ . }}
{{- end }}
{{- with .readOnly }}
readOnly: {{ . }}
{{- end }}
{{- end }}
{{- include "vm.license.mount" . | nindent 12 }}
{{- end }}
{{- with $app.extraContainers }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $app.nodeSelector }}
nodeSelector: {{ toYaml . | nindent 8 }}
{{- end }}
{{- if $app.podSecurityContext.enabled }}
securityContext: {{ include "vm.securityContext" (dict "securityContext" $app.podSecurityContext "helm" .) | nindent 8 }}
{{- end }}
{{- if or (.Values.serviceAccount).name (.Values.serviceAccount).create }}
serviceAccountName: {{ tpl ((.Values.serviceAccount).name | default $sa) $ctx }}
automountServiceAccountToken: {{ .Values.serviceAccount.automountToken }}
{{- end }}
{{- with $app.tolerations }}
tolerations: {{ toYaml . | nindent 8 }}
{{- end }}
{{- with $app.affinity }}
affinity: {{ toYaml . | nindent 8 }}
{{- end }}
{{- with $app.topologySpreadConstraints }}
topologySpreadConstraints:
{{- range $constraint := . }}
- {{ toYaml $constraint | nindent 10 | trim }}
{{- if not $constraint.labelSelector }}
labelSelector:
matchLabels: {{ include "vm.selectorLabels" $ctx | nindent 14 }}
{{- end }}
{{- end }}
{{- end }}
terminationGracePeriodSeconds: {{ $app.terminationGracePeriodSeconds }}
{{- if or $app.extraVolumes (not $pvc.enabled) $pvc.existingClaim (include "vm.license.volume" .) }}
volumes:
{{- with $app.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if or (not $pvc.enabled) $pvc.existingClaim }}
- name: vmstorage-volume
{{- if $pvc.enabled }}
persistentVolumeClaim:
claimName: {{ $pvc.existingClaim }}
{{- else }}
emptyDir: {{ toYaml $app.emptyDir | nindent 12 }}
{{- end }}
{{- end }}
{{- include "vm.license.volume" . | nindent 8 }}
{{- end }}
minReadySeconds: {{ $app.minReadySeconds }}
{{- if and $pvc.enabled (not $pvc.existingClaim) }}
volumeClaimTemplates:
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ tpl $pvc.name $ctx }}
{{- with $pvc.annotations }}
annotations: {{ toYaml . | nindent 10 }}
{{- end }}
{{- with $pvc.extraLabels }}
labels: {{ toYaml . | nindent 10 }}
{{- end }}
spec:
{{- with $pvc.accessModes }}
accessModes: {{ toYaml . | nindent 10 }}
{{- end }}
resources:
requests:
storage: {{ $pvc.size }}
{{- with $pvc.storageClassName }}
storageClassName: {{ ternary "" . (eq "-" .) }}
{{- end }}
{{- end }}
{{- end }}