added repo
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
{{- define "vmagent.args" -}}
|
||||
{{- $args := default dict -}}
|
||||
{{- $Values := (.helm).Values | default .Values -}}
|
||||
{{- if empty $Values.remoteWrite -}}
|
||||
{{- fail "Please define at least one remoteWrite" -}}
|
||||
{{- end -}}
|
||||
{{- $_ := set $args "promscrape.config" "/config/scrape/scrape.yml" -}}
|
||||
{{- $_ := set $args "remoteWrite.tmpDataPath" "/tmpData" -}}
|
||||
{{- range $i, $rw := $Values.remoteWrite -}}
|
||||
{{- if not $rw.url -}}
|
||||
{{- fail (printf "`url` is not set for `remoteWrite` idx %d" $i) -}}
|
||||
{{- end -}}
|
||||
{{- range $rwKey, $rwValue := $rw -}}
|
||||
{{- $key := printf "remoteWrite.%s" $rwKey -}}
|
||||
{{- $param := index $args $key | default list -}}
|
||||
{{- range until (int (sub $i (len $param))) }}
|
||||
{{- $param = append $param "" }}
|
||||
{{- end }}
|
||||
{{- if or (kindIs "slice" $rwValue) (kindIs "map" $rwValue) -}}
|
||||
{{- $param = append $param (printf "/config/rw/%d-%s.yaml" $i $rwKey) }}
|
||||
{{- else -}}
|
||||
{{- $param = append $param $rwValue }}
|
||||
{{- end -}}
|
||||
{{- $_ := set $args $key $param -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $args = mergeOverwrite $args (fromYaml (include "vm.license.flag" .)) -}}
|
||||
{{- $args = mergeOverwrite $args $Values.extraArgs -}}
|
||||
{{- if and (eq $Values.mode "statefulSet") $Values.statefulSet.clusterMode }}
|
||||
{{- $_ := set $args "promscrape.cluster.membersCount" $Values.replicaCount -}}
|
||||
{{- $_ := set $args "promscrape.cluster.replicationFactor" $Values.statefulSet.replicationFactor -}}
|
||||
{{- $_ := set $args "promscrape.cluster.memberNum" "$(POD_NAME)" -}}
|
||||
{{- end -}}
|
||||
{{- toYaml (fromYaml (include "vm.args" $args)).args -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "vmagent.rw.config" -}}
|
||||
{{- $Values := (.helm).Values | default .Values -}}
|
||||
{{- $rwcm := default dict }}
|
||||
{{- range $i, $rw := $Values.remoteWrite }}
|
||||
{{- range $rwKey, $rwValue := $rw }}
|
||||
{{- if or (kindIs "slice" $rwValue) (kindIs "map" $rwValue) }}
|
||||
{{- $rwContent := toYaml $rwValue }}
|
||||
{{- if $Values.config.useTpl }}
|
||||
{{- $rwContent = tpl $rwContent $ | trim }}
|
||||
{{- end }}
|
||||
{{- $_ := set $rwcm (printf "%d-%s.yaml" $i $rwKey) $rwContent }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- toYaml $rwcm -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "vmagent.scrape.config.name" -}}
|
||||
{{- $Values := (.helm).Values | default .Values -}}
|
||||
{{- $fullname := include "vm.plain.fullname" . -}}
|
||||
{{- $Values.configMap | default (printf "%s-config" $fullname) -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,40 @@
|
||||
{{- $ctx := dict "helm" . }}
|
||||
{{- $fullname := include "vm.plain.fullname" $ctx }}
|
||||
{{- $ns := include "vm.namespace" $ctx }}
|
||||
{{- if and (empty .Values.configMap) .Values.config }}
|
||||
{{- $cfg := deepCopy .Values.config }}
|
||||
{{- if .Values.extraScrapeConfigs }}
|
||||
{{- $_ := set $cfg "scrape_configs" (concat (.Values.config.scrape_configs | default list) .Values.extraScrapeConfigs) }}
|
||||
{{- end }}
|
||||
{{- $data := toYaml (omit $cfg "useTpl") }}
|
||||
{{- if $cfg.useTpl }}
|
||||
{{- $data = tpl $data . }}
|
||||
{{- end }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ include "vmagent.scrape.config.name" $ctx }}
|
||||
namespace: {{ $ns }}
|
||||
labels: {{ include "vm.labels" $ctx | nindent 4 }}
|
||||
data:
|
||||
scrape.yml: |{{ $data | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- $rwcm := default dict }}
|
||||
{{- range $i, $rw := .Values.remoteWrite }}
|
||||
{{- range $rwKey, $rwValue := $rw }}
|
||||
{{- if or (kindIs "slice" $rwValue) (kindIs "map" $rwValue) }}
|
||||
{{- $_ := set $rwcm (printf "%d-%s.yaml" $i $rwKey) (toYaml $rwValue) }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- with (include "vmagent.rw.config" .) }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ $fullname }}-rw
|
||||
namespace: {{ $ns }}
|
||||
labels: {{ include "vm.labels" $ctx | nindent 4 }}
|
||||
data: {{ . | nindent 2 }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,4 @@
|
||||
{{ range .Values.extraObjects }}
|
||||
---
|
||||
{{ tpl (ternary . (toYaml .) (typeIs "string" .)) $ }}
|
||||
{{ end }}
|
||||
@@ -0,0 +1,25 @@
|
||||
{{- $hpa := .Values.horizontalPodAutoscaling }}
|
||||
{{- if $hpa.enabled }}
|
||||
{{- $ctx := dict "helm" . }}
|
||||
{{- $fullname := include "vm.plain.fullname" $ctx }}
|
||||
{{- $ns := include "vm.namespace" $ctx }}
|
||||
apiVersion: autoscaling/v2
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
{{- $_ := set $ctx "extraLabels" .Values.extraLabels }}
|
||||
labels: {{ include "vm.labels" $ctx | nindent 4 }}
|
||||
{{- $_ := unset $ctx "extraLabels" }}
|
||||
name: {{ $fullname }}
|
||||
namespace: {{ $ns }}
|
||||
spec:
|
||||
maxReplicas: {{ $hpa.maxReplicas }}
|
||||
minReplicas: {{ $hpa.minReplicas }}
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
kind: {{ title .Values.mode }}
|
||||
name: {{ $fullname }}
|
||||
metrics: {{ toYaml $hpa.metrics | nindent 4 }}
|
||||
{{- with $hpa.behavior }}
|
||||
behavior: {{ toYaml . | nindent 4 }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,45 @@
|
||||
{{- $app := .Values }}
|
||||
{{- $ingress := $app.ingress }}
|
||||
{{- if $ingress.enabled }}
|
||||
{{- if not $app.service.enabled }}
|
||||
{{- fail "It's required to set .Values.service.enabled: true when .Values.ingress.enabled: true"}}
|
||||
{{- end }}
|
||||
{{- $ctx := dict "helm" . }}
|
||||
{{- $fullname := include "vm.fullname" $ctx }}
|
||||
{{- $ns := include "vm.namespace" $ctx }}
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
{{- with $ingress.annotations }}
|
||||
annotations: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- $_ := set $ctx "extraLabels" $app.ingress.extraLabels }}
|
||||
labels: {{ include "vm.labels" $ctx | nindent 4 }}
|
||||
{{- $_ := unset $ctx "extraLabels" }}
|
||||
name: {{ $fullname }}
|
||||
namespace: {{ $ns }}
|
||||
spec:
|
||||
{{- with $ingress.ingressClassName }}
|
||||
ingressClassName: {{ . }}
|
||||
{{- end }}
|
||||
{{- with $ingress.tls }}
|
||||
tls: {{ tpl (toYaml .) $ | nindent 4 }}
|
||||
{{- end }}
|
||||
rules:
|
||||
{{- range $host := $ingress.hosts }}
|
||||
{{- $paths := ternary (list $host.path) $host.path (kindIs "string" $host.path) }}
|
||||
- host: {{ tpl .name $ | quote }}
|
||||
http:
|
||||
paths:
|
||||
{{- range $path := $paths }}
|
||||
- path: {{ $path }}
|
||||
{{- with $ingress.pathType }}
|
||||
pathType: {{ . }}
|
||||
{{- end }}
|
||||
backend:
|
||||
service:
|
||||
name: {{ $fullname }}
|
||||
port: {{ include "vm.ingress.port" $host | nindent 18 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,11 @@
|
||||
{{- $ctx := dict "helm" . }}
|
||||
{{- $ns := include "vm.namespace" $ctx }}
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ include "vmagent.scrape.config.name" $ctx }}
|
||||
namespace: {{ $ns }}
|
||||
labels: {{ include "vm.labels" $ctx | nindent 4 }}
|
||||
data:
|
||||
scrape.yml: |
|
||||
{{ .Files.Get (printf "%s/%s" .Values.custom.configFileFolderPath .Values.custom.scrapeConfigFileName) | indent 4 }}
|
||||
@@ -0,0 +1,51 @@
|
||||
{{- $serviceMonitor := .Values.serviceMonitor -}}
|
||||
{{- if $serviceMonitor.enabled -}}
|
||||
{{- $ctx := dict "helm" . }}
|
||||
{{- $fullname := include "vm.plain.fullname" $ctx }}
|
||||
{{- $ns := include "vm.namespace" $ctx }}
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: ServiceMonitor
|
||||
metadata:
|
||||
{{- with $serviceMonitor.annotations }}
|
||||
annotations: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- $_ := set $ctx "extraLabels" $serviceMonitor.extraLabels }}
|
||||
labels: {{ include "vm.labels" $ctx | nindent 4 }}
|
||||
{{- $_ := unset $ctx "extraLabels" }}
|
||||
name: {{ $fullname }}
|
||||
{{- with $serviceMonitor.namespace }}
|
||||
namespace: {{ . }}
|
||||
{{- end }}
|
||||
spec:
|
||||
namespaceSelector:
|
||||
matchNames:
|
||||
- {{ $ns }}
|
||||
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 }}
|
||||
{{- with $serviceMonitor.targetPort }}
|
||||
targetPort: {{ . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,23 @@
|
||||
{{- $pdb := .Values.podDisruptionBudget }}
|
||||
{{- if $pdb.enabled }}
|
||||
{{- $ctx := dict "helm" . }}
|
||||
{{- $fullname := include "vm.plain.fullname" $ctx }}
|
||||
{{- $ns := include "vm.namespace" $ctx }}
|
||||
apiVersion: policy/v1
|
||||
kind: PodDisruptionBudget
|
||||
metadata:
|
||||
name: {{ $fullname }}
|
||||
namespace: {{ $ns }}
|
||||
{{- $_ := set $ctx "extraLabels" $pdb.labels }}
|
||||
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 }}
|
||||
@@ -0,0 +1,33 @@
|
||||
{{- $app := .Values }}
|
||||
{{- $pvc := $app.persistentVolume }}
|
||||
{{- if and $pvc.enabled (not $pvc.existingClaim) (eq $app.mode "deployment") }}
|
||||
{{- $ctx := dict "helm" . }}
|
||||
{{- $fullname := include "vm.fullname" $ctx }}
|
||||
{{- $ns := include "vm.namespace" $ctx }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: {{ tpl ($pvc.name | default $fullname) $ctx }}
|
||||
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 }}
|
||||
@@ -0,0 +1,72 @@
|
||||
{{- if .Values.rbac.create -}}
|
||||
{{- $ctx := dict "helm" . }}
|
||||
{{- $fullname := include "vm.plain.fullname" $ctx }}
|
||||
{{- $namespaced := .Values.rbac.namespaced }}
|
||||
{{- $ns := include "vm.namespace" $ctx }}
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: {{ ternary "RoleBinding" "ClusterRoleBinding" $namespaced }}
|
||||
metadata:
|
||||
name: {{ $fullname }}
|
||||
{{- if $namespaced }}
|
||||
namespace: {{ $ns }}
|
||||
{{- end }}
|
||||
{{- $_ := set $ctx "extraLabels" .Values.rbac.extraLabels }}
|
||||
labels: {{ include "vm.labels" $ctx | nindent 4 }}
|
||||
{{- $_ := unset $ctx "extraLabels" }}
|
||||
{{- with .Values.rbac.annotations }}
|
||||
annotations: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: {{ ternary "Role" "ClusterRole" $namespaced }}
|
||||
name: {{ $fullname }}
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ (.Values.serviceAccount).name | default $fullname }}
|
||||
namespace: {{ $ns }}
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: {{ ternary "Role" "ClusterRole" $namespaced }}
|
||||
metadata:
|
||||
name: {{ $fullname }}
|
||||
{{- if $namespaced }}
|
||||
namespace: {{ include "vm.namespace" $ctx }}
|
||||
{{- end }}
|
||||
{{- $_ := set $ctx "extraLabels" .Values.rbac.extraLabels }}
|
||||
labels: {{ include "vm.labels" $ctx | nindent 4 }}
|
||||
{{- $_ := unset $ctx "extraLabels" }}
|
||||
{{- with .Values.rbac.annotations }}
|
||||
annotations: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
rules:
|
||||
- apiGroups:
|
||||
- discovery.k8s.io
|
||||
resources:
|
||||
- endpointslices
|
||||
verbs: ["get", "list", "watch"]
|
||||
- apiGroups: [""]
|
||||
resources:
|
||||
- services
|
||||
- endpoints
|
||||
- pods
|
||||
verbs: ["get", "list", "watch"]
|
||||
- apiGroups:
|
||||
- networking.k8s.io
|
||||
resources:
|
||||
- ingresses
|
||||
verbs: ["get", "list", "watch"]
|
||||
{{- with .Values.rbac.extraRules }}
|
||||
{{ toYaml . }}
|
||||
{{- end }}
|
||||
{{- if not $namespaced }}
|
||||
- apiGroups: [""]
|
||||
resources:
|
||||
- nodes
|
||||
- nodes/proxy
|
||||
- nodes/metrics
|
||||
verbs: ["get", "list", "watch"]
|
||||
- nonResourceURLs: {{ toYaml .Values.allowedMetricsEndpoints | nindent 2 }}
|
||||
verbs: ["get"]
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,43 @@
|
||||
{{- $app := .Values }}
|
||||
{{- $route := $app.route }}
|
||||
{{- if $route.enabled }}
|
||||
{{- $ctx := dict "helm" . }}
|
||||
{{- $fullname := include "vm.plain.fullname" $ctx }}
|
||||
{{- $ns := include "vm.namespace" $ctx }}
|
||||
---
|
||||
apiVersion: {{ $route.apiVersion | default "gateway.networking.k8s.io/v1" }}
|
||||
kind: {{ $route.kind | default "HTTPRoute" }}
|
||||
metadata:
|
||||
name: {{ $fullname }}
|
||||
namespace: {{ $ns }}
|
||||
{{- $_ := set $ctx "extraLabels" $app.route.extraLabels }}
|
||||
labels: {{ include "vm.labels" $ctx | nindent 4 }}
|
||||
{{- $_ := unset $ctx "extraLabels" }}
|
||||
{{- 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 }}
|
||||
@@ -0,0 +1,234 @@
|
||||
{{- $storageName := "tmpdata" }}
|
||||
{{- $app := .Values }}
|
||||
{{- $pvc := $app.persistentVolume }}
|
||||
{{- $mode := $app.mode }}
|
||||
{{- if and $mode (hasKey $app $mode) }}
|
||||
{{- $modeOpts := index $app $mode }}
|
||||
{{- $ctx := dict "helm" . }}
|
||||
{{- $fullname := include "vm.plain.fullname" $ctx }}
|
||||
{{- $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 .Values.annotations }}
|
||||
annotations: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- with $modeOpts.spec }}
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- if and (not $app.horizontalPodAutoscaling.enabled) (ne $mode "daemonSet") }}
|
||||
replicas: {{ $app.replicaCount }}
|
||||
{{- end }}
|
||||
{{- if eq $mode "statefulSet" }}
|
||||
serviceName: {{ $fullname }}
|
||||
{{- end }}
|
||||
selector:
|
||||
{{- $_ := set $ctx "extraLabels" .Values.selectorLabels }}
|
||||
matchLabels: {{ include "vm.selectorLabels" $ctx | nindent 6 }}
|
||||
{{- $_ := unset $ctx "extraLabels" }}
|
||||
template:
|
||||
metadata:
|
||||
{{- $_ := set $ctx "extraLabels" $app.podLabels }}
|
||||
labels: {{ include "vm.podLabels" $ctx | nindent 8 }}
|
||||
{{- $_ := unset $ctx "extraLabels" }}
|
||||
{{- $annotations := merge (dict "checksum/config" (include (print .Template.BasePath "/configmap.yaml") . | sha256sum)) (deepCopy $app.podAnnotations) }}
|
||||
annotations: {{ toYaml $annotations | nindent 8 }}
|
||||
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 $fullname) $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 }}
|
||||
{{- with $app.hostAliases }}
|
||||
hostAliases: {{ toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: vmagent
|
||||
{{- if $app.securityContext.enabled }}
|
||||
securityContext: {{ include "vm.securityContext" (dict "securityContext" $app.securityContext "helm" .) | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- $_ := set $ctx "app" $app }}
|
||||
image: {{ include "vm.image" $ctx }}
|
||||
imagePullPolicy: {{ $app.image.pullPolicy }}
|
||||
{{- with $app.containerWorkingDir }}
|
||||
workingDir: {{ . }}
|
||||
{{- end }}
|
||||
args: {{ include "vmagent.args" $ctx | nindent 12 }}
|
||||
{{- with $app.envFrom }}
|
||||
envFrom: {{ toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
env:
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.name
|
||||
{{- with $app.env }}
|
||||
{{ toYaml .| nindent 12 }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: {{ include "vm.port.from.flag" (dict "flag" $app.extraArgs.httpListenAddr "default" "8429") }}
|
||||
{{- 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 }}
|
||||
{{- with $app.resources }}
|
||||
resources: {{ toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
- name: {{ $storageName }}
|
||||
mountPath: /tmpData
|
||||
- name: scrape-config
|
||||
mountPath: /config/scrape
|
||||
{{- with (include "vmagent.rw.config" .) }}
|
||||
- name: rw-config
|
||||
mountPath: /config/rw
|
||||
{{- end }}
|
||||
{{- range $app.extraHostPathMounts }}
|
||||
- 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 }}
|
||||
{{- with $app.extraContainers }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with $app.nodeSelector }}
|
||||
nodeSelector: {{ toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with $app.affinity }}
|
||||
affinity: {{ toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with $app.tolerations }}
|
||||
tolerations: {{ toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if and ($app.hostNetwork) (eq $mode "daemonSet") }}
|
||||
hostNetwork: true
|
||||
{{- 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:
|
||||
{{- if or (eq $mode "deployment") (not $pvc.enabled) $pvc.existingClaim }}
|
||||
- name: {{ $storageName }}
|
||||
{{- if or (and (eq $mode "deployment") $pvc.enabled) $pvc.existingClaim }}
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ tpl ($pvc.existingClaim | default $pvc.name | default $fullname) $ctx }}
|
||||
{{- else }}
|
||||
emptyDir: {{ toYaml $app.emptyDir | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- with (include "vmagent.rw.config" .) }}
|
||||
- name: rw-config
|
||||
configMap:
|
||||
name: {{ $fullname -}}-rw
|
||||
{{- end }}
|
||||
- name: scrape-config
|
||||
configMap:
|
||||
name: {{ include "vmagent.scrape.config.name" $ctx }}
|
||||
{{- range $app.extraHostPathMounts }}
|
||||
- name: {{ .name }}
|
||||
hostPath:
|
||||
path: {{ .hostPath }}
|
||||
{{- end }}
|
||||
{{- with $app.extraVolumes }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- 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 | default $storageName) $ctx }}
|
||||
{{- with $pvc.extraLabels }}
|
||||
labels: {{ toYaml . | nindent 10 }}
|
||||
{{- end }}
|
||||
{{- with $pvc.annotations }}
|
||||
annotations: {{ toYaml . | nindent 10 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- with $pvc.accessModes }}
|
||||
accessModes: {{ toYaml . | nindent 10 }}
|
||||
{{- end }}
|
||||
{{- with $pvc.storageClassName }}
|
||||
storageClassName: {{ . }}
|
||||
{{- end }}
|
||||
{{- with $pvc.matchLabels }}
|
||||
selector:
|
||||
matchLabels: {{ toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ $pvc.size }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,97 @@
|
||||
{{- $app := .Values }}
|
||||
{{- $service := $app.service }}
|
||||
{{- if $service.enabled -}}
|
||||
{{- $ctx := dict "helm" . }}
|
||||
{{- $fullname := include "vm.plain.fullname" $ctx }}
|
||||
{{- $ns := include "vm.namespace" $ctx }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
{{- with $service.annotations }}
|
||||
annotations: {{ toYaml . | nindent 4}}
|
||||
{{- end }}
|
||||
{{- $_ := set $ctx "extraLabels" $service.extraLabels }}
|
||||
labels: {{ include "vm.labels" $ctx | nindent 4 }}
|
||||
{{- $_ := unset $ctx "extraLabels" }}
|
||||
name: {{ $fullname }}
|
||||
namespace: {{ $ns }}
|
||||
spec:
|
||||
{{- with $service.clusterIP }}
|
||||
clusterIP: {{ . }}
|
||||
{{- end }}
|
||||
{{- with $service.externalIPs }}
|
||||
externalIPs: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with $service.loadBalancerIP }}
|
||||
loadBalancerIP: {{ . }}
|
||||
{{- end }}
|
||||
{{- with $service.loadBalancerSourceRanges }}
|
||||
loadBalancerSourceRanges: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
type: {{ $service.type }}
|
||||
{{- with $service.healthCheckNodePort }}
|
||||
healthCheckNodePort: {{ . }}
|
||||
{{- end }}
|
||||
{{- with $service.externalTrafficPolicy }}
|
||||
externalTrafficPolicy: {{ . }}
|
||||
{{- end }}
|
||||
{{- with $service.internalTrafficPolicy }}
|
||||
internalTrafficPolicy: {{ . }}
|
||||
{{- 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 }}
|
||||
{{- with $service.nodePort }}
|
||||
nodePort: {{ . }}
|
||||
{{- end }}
|
||||
{{- with .Values.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 .Values.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 .Values.extraArgs.opentsdbHTTPListenAddr }}
|
||||
- name: opentsdbhttp
|
||||
port: {{ include "vm.port.from.flag" (dict "flag" .) }}
|
||||
targetPort: opentsdbhttp
|
||||
{{- end }}
|
||||
{{- with .Values.extraArgs.opentsdbListenAddr }}
|
||||
- name: opentsdb-udp
|
||||
protocol: UDP
|
||||
port: {{ include "vm.port.from.flag" (dict "flag" .) }}
|
||||
targetPort: opentsdb-udp
|
||||
- name: opentsdb-tcp
|
||||
protocol: TCP
|
||||
port: {{ include "vm.port.from.flag" (dict "flag" .) }}
|
||||
targetPort: opentsdb-tcp
|
||||
{{- end }}
|
||||
{{- $_ := set $ctx "extraLabels" (mergeOverwrite (deepCopy .Values.selectorLabels) (deepCopy $service.selectorLabels)) }}
|
||||
selector: {{ include "vm.selectorLabels" $ctx | nindent 4 }}
|
||||
{{- $_ := unset $ctx "extraLabels" }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,14 @@
|
||||
{{- if .Values.serviceAccount.create -}}
|
||||
{{- $ctx := dict "helm" . }}
|
||||
{{- $fullname := include "vm.plain.fullname" $ctx }}
|
||||
{{- $ns := include "vm.namespace" $ctx }}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ tpl ((.Values.serviceAccount).name | default $fullname) $ctx }}
|
||||
namespace: {{ $ns }}
|
||||
labels: {{ include "vm.labels" $ctx | nindent 4 }}
|
||||
{{- with .Values.serviceAccount.annotations }}
|
||||
annotations: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
Reference in New Issue
Block a user