Skip to content

enhancement: modified the chart 4.21 and added support for the vmservice scrape and vm rule #6623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -527,4 +527,6 @@ hostAliases: []
# - "bar.remote"

verticalPodScaling:
enabled: false
enabled: false

MetricsScraper: Prometheus
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,44 @@ Create chart name and version as used by the chart label.
{{- $LabelsContain = true -}}
{{- end }}
{{- $LabelsContain -}}
{{- end -}}
{{- end -}}

{{- define "vmserviceScrapeEnabled" -}}
{{- $SMenabled := false -}}
{{- range .Values.ContainerPort }}
{{- if .vmservicescrape }}
{{- if and .vmservicescrape.enabled }}
{{- $SMenabled = true -}}
{{- end }}
{{- end }}
{{- end }}
{{- $SMenabled -}}
{{- end -}}


{{- define "podMonitorEnabled" -}}
{{- $SMenabled := false -}}
{{- if .Values.podmonitor.enabled }}
{{- $SMenabled = true -}}
{{- end }}
{{- $SMenabled -}}
{{- end -}}


{{- define "scrapeType" -}}
{{- $ServiceMonitorEnabled := include "serviceMonitorEnabled" . -}}
{{- $VmServiceScrapeEnabled := include "vmserviceScrapeEnabled" . -}}
{{- $val1 := "vmservicescrape"}}
{{- $val2 := "servicemonitor"}}
{{- $val3 := "" }}
{{- if and (eq $VmServiceScrapeEnabled "true") (eq $ServiceMonitorEnabled "true")}}
{{- $val1 }}
{{- else if eq $ServiceMonitorEnabled "true" }}
{{- $val2 }}
{{- else if eq $VmServiceScrapeEnabled "true" }}
{{- $val1 }}
{{- else }}
{{- $val3 }}
{{- end }}

{{- end }}
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{{- if $.Values.appMetrics -}}
{{- if eq .Values.MetricsScraper "Victoria" }}
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMServiceScrape
{{- else if eq .Values.MetricsScraper "Prometheus" }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
{{- end }}
metadata:
name: {{ template ".Chart.Name .fullname" $ }}
labels:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ spec:
{{- end }}
env:
- name: CONFIG_HASH
value: {{ include (print $.Chart.Name "/templates/configmap.yaml") . | sha256sum }}{{ if and (.Values.devtronInternal) (.Values.devtronInternal.containerSpecs.ConfigHash) }}{{ .Values.devtronInternal.containerSpecs.ConfigHash }}{{ end }}
value: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}{{ if and (.Values.devtronInternal) (.Values.devtronInternal.containerSpecs.ConfigHash) }}{{ .Values.devtronInternal.containerSpecs.ConfigHash }}{{ end }}
- name: SECRET_HASH
value: {{ include (print $.Chart.Name "/templates/secret.yaml") . | sha256sum }}{{ if and (.Values.devtronInternal) (.Values.devtronInternal.containerSpecs.SecretHash) }}{{ .Values.devtronInternal.containerSpecs.SecretHash }}{{ end }}
value: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}{{ if and (.Values.devtronInternal) (.Values.devtronInternal.containerSpecs.SecretHash) }}{{ .Values.devtronInternal.containerSpecs.SecretHash }}{{ end }}
- name: DEVTRON_APP_NAME
value: {{ template ".Chart.Name .name" $ }}
- name: POD_NAME
Expand Down Expand Up @@ -571,8 +571,20 @@ spec:
{{ toYaml .volumeMounts | indent 12 -}}
{{- end}}
{{- else}}
{{- $cCopy := deepCopy . }}
{{- if hasKey $cCopy "ports" }}
{{- $newPorts := list }}
{{- range $port := $cCopy.ports }}
{{- $newPorts = append $newPorts (dict
"name" (get $port "name")
"containerPort" (get $port "containerPort")
"protocol" (get $port "protocol")
) }}
{{- end }}
{{- $_ := set $cCopy "ports" $newPorts }}
{{- end }}
-
{{ toYaml . | indent 10 }}
{{ toYaml $cCopy | indent 10 }}
{{- end}}
{{- end}}
{{- end}}
Expand Down Expand Up @@ -874,9 +886,9 @@ spec:
{{- end }}
env:
- name: CONFIG_HASH
value: {{ include (print $.Chart.Name "/templates/configmap.yaml") . | sha256sum }}{{ if and (.Values.devtronInternal) (.Values.devtronInternal.containerSpecs.ConfigHash) }}{{ .Values.devtronInternal.containerSpecs.ConfigHash }}{{ end }}
value: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}{{ if and (.Values.devtronInternal) (.Values.devtronInternal.containerSpecs.ConfigHash) }}{{ .Values.devtronInternal.containerSpecs.ConfigHash }}{{ end }}
- name: SECRET_HASH
value: {{ include (print $.Chart.Name "/templates/secret.yaml") . | sha256sum }}{{ if and (.Values.devtronInternal) (.Values.devtronInternal.containerSpecs.SecretHash) }}{{ .Values.devtronInternal.containerSpecs.SecretHash }}{{ end }}
value: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}{{ if and (.Values.devtronInternal) (.Values.devtronInternal.containerSpecs.SecretHash) }}{{ .Values.devtronInternal.containerSpecs.SecretHash }}{{ end }}
- name: DEVTRON_APP_NAME
value: {{ template ".Chart.Name .name" $ }}
- name: POD_NAME
Expand Down Expand Up @@ -1186,8 +1198,20 @@ spec:
{{ toYaml .volumeMounts | indent 12 -}}
{{- end}}
{{- else}}
{{- $cCopy := deepCopy . }}
{{- if hasKey $cCopy "ports" }}
{{- $newPorts := list }}
{{- range $port := $cCopy.ports }}
{{- $newPorts = append $newPorts (dict
"name" (get $port "name")
"containerPort" (get $port "containerPort")
"protocol" (get $port "protocol")
) }}
{{- end }}
{{- $_ := set $cCopy "ports" $newPorts }}
{{- end }}
-
{{ toYaml . | indent 10 }}
{{ toYaml $cCopy | indent 10 }}
{{- end}}
{{- end}}
{{- end}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ metadata:
{{ toYaml .annotations | indent 4 }}
{{- end }}
spec:
{{- if .provider }}
provider: {{ .provider }}
{{- end }}
targetRef:
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -146,13 +149,31 @@ spec:
maxWeight: {{ .analysis.maxWeight }}
stepWeight: {{ .analysis.stepWeight }}
metrics:
{{- if $.Values.flaggerCanary.analysis.metrics }}
{{- range $.Values.flaggerCanary.analysis.metrics }}
- name: {{ .name }}
threshold: {{ .successRate }}
interval: {{.interval }}
{{- end }}
{{- end }}
- name: request-success-rate
threshold: {{ .thresholds.successRate }}
interval: 1m
- name: request-duration
threshold: {{ .thresholds.latency }}
interval: 1m
interval: 1m
webhooks:
{{- if $.Values.flaggerCanary.analysis.webhooks }}
{{- range $.Values.flaggerCanary.analysis.webhooks }}
- name: {{ .name }}
url: {{ .url }}
timeout: {{ .timeout }}
metadata:
{{- range $key, $val := .metadata }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- if .loadtest.enabled }}
- name: load-test
url: {{ .loadtest.url }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{{- with .Values.istio }}
{{- if and .enable .authorizationPolicy.enabled }}
{{ if semverCompare ">=1.22-0" $.Capabilities.KubeVersion.GitVersion -}}
apiVersion: security.istio.io/v1
{{- else -}}
apiVersion: security.istio.io/v1beta1
{{- end }}
kind: AuthorizationPolicy
metadata:
{{- if .authorizationPolicy.name }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{{- with .Values.istio }}
{{- if and .enable .destinationRule.enabled }}
{{ if semverCompare ">=1.22-0" $.Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.istio.io/v1
{{ else }}
apiVersion: networking.istio.io/v1beta1
{{- end }}
kind: DestinationRule
metadata:
{{- if .destinationRule.name }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{{- if and .Values.istio.enable .Values.istio.gateway.enabled -}}
{{ if semverCompare ">=1.22-0" $.Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.istio.io/v1
{{ else }}
apiVersion: networking.istio.io/v1beta1
{{- end }}
kind: Gateway
metadata:
{{- if .Values.istio.gateway.name }}
Expand All @@ -24,6 +28,9 @@ metadata:
{{ toYaml $.Values.istio.gateway.annotations | indent 4 }}
{{- end }}
spec:
{{- if .Values.istio.gateway.gatewayExtraSpec }}
{{ toYaml $.Values.istio.gateway.gatewayExtraSpec | indent 2}}
{{- end }}
{{ with $.Values.istio.gateway }}
selector:
{{- if .selector }}
Expand Down Expand Up @@ -68,4 +75,4 @@ spec:
{{ end }}
{{ end }}
{{ end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{{- with .Values.istio }}
{{- if and .enable .peerAuthentication.enabled }}
{{ if semverCompare ">=1.22-0" $.Capabilities.KubeVersion.GitVersion -}}
apiVersion: security.istio.io/v1
{{- else -}}
apiVersion: security.istio.io/v1beta1
{{- end }}
kind: PeerAuthentication
metadata:
{{- if .peerAuthentication.name }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{{- with .Values.istio }}
{{- if and .enable .requestAuthentication.enabled }}
{{ if semverCompare ">=1.22-0" $.Capabilities.KubeVersion.GitVersion -}}
apiVersion: security.istio.io/v1
{{- else -}}
apiVersion: security.istio.io/v1beta1
{{- end }}
kind: RequestAuthentication
metadata:
{{- if .requestAuthentication.name }}
name: {{.requestAuthentication.name }}
name: {{ .requestAuthentication.name }}
{{- else }}
name: {{ template ".Chart.Name .fullname" $ }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{{- with .Values.istio }}
{{- if and .enable .virtualService.enabled }}
{{ if semverCompare ">=1.22-0" $.Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.istio.io/v1
{{ else }}
apiVersion: networking.istio.io/v1beta1
{{- end }}
kind: VirtualService
metadata:
{{- if .virtualService.name }}
Expand All @@ -25,6 +29,9 @@ metadata:
{{ toYaml .virtualService.annotations | indent 4 }}
{{- end }}
spec:
{{- if .virtualService.virtualServiceExtraSpec }}
{{ toYaml .virtualService.virtualServiceExtraSpec | indent 2}}
{{- end }}
{{- if or .gateway.enabled .virtualService.gateways }}
gateways:
{{- if .gateway.enabled }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{ $podMonitorEnabled := include "podMonitorEnabled" . }}
{{- if eq "true" $podMonitorEnabled -}}
---
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
{{- if .Values.podmonitor.name }}
name: {{ .Values.podmonitor.name }}
{{- else }}
name: {{ template ".Chart.Name .fullname" . }}-pm
{{- end }}
spec:
jobLabel: {{ .Values.podmonitor.jobLabel }}
namespaceSelector:
matchNames:
- devtron-demo
{{- if .Values.podmonitor.podMetricsEndpoints }}
podMetricsEndpoints:
{{- toYaml .Values.podmonitor.podMetricsEndpoints | nindent 4}}
{{- end }}
podTargetLabels:
- appId
- envId
- devtron_app_hash
selector:
matchLabels:
{{- if .Values.podmonitor.matchLabels }}
{{- toYaml .Values.pod.matchLabels | nindent 6 }}
{{- else }}
app: {{ template ".Chart.Name .name" $ }}
{{- end }}
{{- end }}
Loading
Loading