Skip to content

Commit

Permalink
Refactor helm configuration(values.yaml) (#58)
Browse files Browse the repository at this point in the history
* Update helm configurations and template yamls
* Updated directory name and readme
* Updated values.yaml
* chart version bumped

Signed-off-by: Sahil Raja <[email protected]>
  • Loading branch information
rajaSahil authored Aug 29, 2021
1 parent 1a92bd6 commit d92c900
Show file tree
Hide file tree
Showing 15 changed files with 514 additions and 519 deletions.
6 changes: 3 additions & 3 deletions deploy/charts/openebs-monitoring/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ dependencies:
version: 16.5.0
- name: node-problem-detector
repository: https://charts.deliveryhero.io/
version: 2.0.3
digest: sha256:d890dae8cd0f47e79d432b71c4febf23ea06134dc68c555ee9fd932441403101
generated: "2021-07-16T00:36:47.179715341+05:30"
version: 2.0.4
digest: sha256:8025e42fa1597e718ff930a5796c02fa6bb5c811d075110ba8f7a121df9dcb3e
generated: "2021-08-20T10:06:45.415344681+05:30"
2 changes: 1 addition & 1 deletion deploy/charts/openebs-monitoring/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ keywords:
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.4.1
version: 0.4.2

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
96 changes: 49 additions & 47 deletions deploy/charts/openebs-monitoring/README.md

Large diffs are not rendered by default.

14 changes: 0 additions & 14 deletions deploy/charts/openebs-monitoring/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,3 @@ Usage:
{{- end }}
{{- include $template (dict "Chart" (dict "Name" (last $subchart)) "Values" $values "Release" $dot.Release "Capabilities" $dot.Capabilities) }}
{{- end }}


{{/*
grafana sidecar dashboards label
*/}}
{{- define "grafana-sidecar-dashboards.label" }}
{{- if and (index .Values "kube-prometheus-stack" "install") (index .Values "kube-prometheus-stack" "grafana" "sidecar" "dashboards" "enabled") }}
{{- $grafanaSidecarDashboardsLabel:= index .Values "kube-prometheus-stack" "grafana" "sidecar" "dashboards" "label" }}
{{- printf $grafanaSidecarDashboardsLabel }}
{{- else if and (.Values.openebsMonitoringAddon.enabled) (.Values.openebsMonitoringAddon.grafana.sidecar.dashboards.enabled )}}
{{- $grafanaSidecarDashboardsLabel:= .Values.openebsMonitoringAddon.grafana.sidecar.dashboards.label }}
{{- printf $grafanaSidecarDashboardsLabel }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
{{- if or (index .Values "kube-prometheus-stack" "grafana" "enabled") (.Values.openebsMonitoringAddon.enabled ) }}
{{- if or (index .Values "kube-prometheus-stack" "grafana" "openebsDashboardsEnabled") (.Values.openebsMonitoringAddon.grafana.openebsDashboardsEnabled )}}
{{- $grafanaSidecarDashboardsLabel := ( include "grafana-sidecar-dashboards.label" $ ) }}
{{- if .Values.customDashboards }}
{{- $customEnabledDashboards := dict -}}
{{- range $dirName,$fields := .Values.customDashboards }}
{{- $grafanaSidecarDashboardsLabel := index .Values "kube-prometheus-stack" "grafana" "sidecar" "dashboards" "label" }}
{{- $dashboards := dict -}}
{{- range $monitoringAddon,$fields := .Values.openebsMonitoringAddon }}
{{- if (and (hasKey $fields "enabled") ($fields.enabled)) }}
{{ $_ := set $customEnabledDashboards $dirName $fields.enabled }}
{{- if (hasKey $fields "dashboards") }}
{{- if ($fields.dashboards.enabled) }}
{{ $_ := set $dashboards $monitoringAddon $fields.dashboards.enabled }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- $files := .Files.Glob "dashboards/**.json" }}
{{- if $files }}
{{- range $fileName, $fileContents := $files }}
{{- $dirName := split "/" $fileName }}
{{- if (hasKey $customEnabledDashboards $dirName._1 ) }}
{{- if and (hasKey $dashboards $dirName._1 ) $dashboards }}
{{- $dashboardName := regexReplaceAll "(^.*/)(.*)\\.json$" $fileName "${2}" }}
apiVersion: v1
kind: ConfigMap
Expand All @@ -29,6 +30,3 @@ data:
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
22 changes: 12 additions & 10 deletions deploy/charts/openebs-monitoring/templates/podmonitors.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
{{- if .Values.podMonitors }}
{{- range $openebsEngine, $fields := .Values.podMonitors }}
{{- range $monitoringAddon, $fields := .Values.openebsMonitoringAddon }}
{{- if (and (hasKey $fields "enabled") ($fields.enabled)) }}
{{- if (hasKey $fields "podMonitor") }}
{{- if ($fields.podMonitor.enabled) }}
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: {{ lower (printf "%s-%s" (include "openebs-monitoring.fullname" $) $openebsEngine) | trunc 63 | trimSuffix "-" }}
name: {{ lower (printf "%s-%s" (include "openebs-monitoring.fullname" $) $monitoringAddon) | trunc 63 | trimSuffix "-" }}
namespace: {{ template "openebs-monitoring.namespace" $ }}
labels:
app: {{ template "openebs-monitoring.name" $ }}-{{ $openebsEngine }}
app: {{ template "openebs-monitoring.name" $ }}-{{ $monitoringAddon }}
{{ include "openebs-monitoring.labels" $ | indent 4 }}
spec:
selector:
{{ toYaml $fields.selector | indent 4 }}
{{ toYaml $fields.podMonitor.selector | indent 4 }}
namespaceSelector:
{{ toYaml $fields.namespaceSelector | indent 4 }}
{{ toYaml $fields.podMonitor.namespaceSelector | indent 4 }}
podMetricsEndpoints:
- targetPort: {{ $fields.podMetricsEndpoints.targetPort }}
path: {{ $fields.podMetricsEndpoints.path }}
{{- if $fields.podMetricsEndpoints.relabelings }}
- targetPort: {{ $fields.podMonitor.podMetricsEndpoints.targetPort }}
path: {{ $fields.podMonitor.podMetricsEndpoints.path }}
{{- if $fields.podMonitor.podMetricsEndpoints.relabelings }}
relabelings:
{{ toYaml $fields.podMetricsEndpoints.relabelings | indent 8 }}
{{ toYaml $fields.podMonitor.podMetricsEndpoints.relabelings | indent 8 }}
{{- end }}
---
{{- end }}
{{- end }}
{{- end }}
{{- end }}
14 changes: 8 additions & 6 deletions deploy/charts/openebs-monitoring/templates/prometheusRules.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
{{- if .Values.alertRules }}
{{- $customEnabledRules := dict -}}
{{- range $dirName,$fields := .Values.alertRules }}
{{- $alertRules := dict -}}
{{- range $monitoringAddon,$fields := .Values.openebsMonitoringAddon }}
{{- if (and (hasKey $fields "enabled") ($fields.enabled)) }}
{{ $_ := set $customEnabledRules $dirName $fields.enabled }}
{{- if (hasKey $fields "alertRules") }}
{{- if ($fields.alertRules.enabled) }}
{{ $_ := set $alertRules $monitoringAddon $fields.alertRules.enabled }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- $files := .Files.Glob "rules/**.json" }}
{{- if $files }}
{{- range $fileName, $fileContents := $files }}
{{- $dirName := split "/" $fileName }}
{{- if (hasKey $customEnabledRules $dirName._1 ) }}
{{- if and (hasKey $alertRules $dirName._1 ) $alertRules }}
{{- $ruleName := regexReplaceAll "(^.*/)(.*)\\.json$" $fileName "${2}" }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
Expand All @@ -21,7 +24,6 @@ metadata:
{{ include "openebs-monitoring.labels" $ | indent 4 }}
spec:
{{ $.Files.Get $fileName | indent 2 }}
{{- end }}
---
{{- end }}
{{- end }}
Expand Down
22 changes: 12 additions & 10 deletions deploy/charts/openebs-monitoring/templates/servicemonitors.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
{{- if .Values.serviceMonitors }}
{{- range $openebsEngine, $fields := .Values.serviceMonitors }}
{{- range $monitoringAddon, $fields := .Values.openebsMonitoringAddon }}
{{- if (and (hasKey $fields "enabled") ($fields.enabled)) }}
{{- if (hasKey $fields "serviceMonitor") }}
{{- if ($fields.serviceMonitor.enabled) }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ lower (printf "%s-%s" (include "openebs-monitoring.fullname" $) $openebsEngine) | trunc 63 | trimSuffix "-" }}
name: {{ lower (printf "%s-%s" (include "openebs-monitoring.fullname" $) $monitoringAddon) | trunc 63 | trimSuffix "-" }}
namespace: {{ template "openebs-monitoring.namespace" $ }}
labels:
app: {{ template "openebs-monitoring.name" $ }}-{{ $openebsEngine }}
app: {{ template "openebs-monitoring.name" $ }}-{{ $monitoringAddon }}
{{ include "openebs-monitoring.labels" $ | indent 4 }}
spec:
selector:
{{ toYaml $fields.selector | indent 4 }}
{{ toYaml $fields.serviceMonitor.selector | indent 4 }}
namespaceSelector:
{{ toYaml $fields.namespaceSelector | indent 4 }}
{{ toYaml $fields.serviceMonitor.namespaceSelector | indent 4 }}
endpoints:
- port: {{ $fields.endpoints.port }}
path: {{ $fields.endpoints.path }}
{{- if $fields.endpoints.relabelings }}
- port: {{ $fields.serviceMonitor.endpoints.port }}
path: {{ $fields.serviceMonitor.endpoints.path }}
{{- if $fields.serviceMonitor.endpoints.relabelings }}
relabelings:
{{ toYaml $fields.endpoints.relabelings | indent 8 }}
{{ toYaml $fields.serviceMonitor.endpoints.relabelings | indent 8 }}
{{- end }}
---
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Loading

0 comments on commit d92c900

Please sign in to comment.