From 61731554e8696741f521c4f077c84b460d173d34 Mon Sep 17 00:00:00 2001 From: Kjeld Schouten-Lebbing Date: Mon, 26 Sep 2022 13:35:03 +0200 Subject: [PATCH] fix(blocky): fix GUI apiurl and prometheus metrics (#3908) * chore(blocky): bump blocky Signed-off-by: Kjeld Schouten-Lebbing * Update _webui.tpl Signed-off-by: Kjeld Schouten-Lebbing * Create servicemonitor.yaml Signed-off-by: Kjeld Schouten-Lebbing * Update common.yaml Signed-off-by: Kjeld Schouten-Lebbing * Update _blockyConfig.tpl Signed-off-by: Kjeld Schouten-Lebbing * Update questions.yaml Signed-off-by: Kjeld Schouten-Lebbing * Update values.yaml Signed-off-by: Kjeld Schouten-Lebbing * Create prometheusrules.yaml Signed-off-by: Kjeld Schouten-Lebbing * Update common.yaml Signed-off-by: Kjeld Schouten-Lebbing * Update _blockyConfig.tpl Signed-off-by: Kjeld Schouten-Lebbing Signed-off-by: Kjeld Schouten-Lebbing --- charts/enterprise/blocky/Chart.yaml | 2 +- charts/enterprise/blocky/questions.yaml | 14 +--------- .../blocky/templates/_blockyConfig.tpl | 2 -- charts/enterprise/blocky/templates/_webui.tpl | 2 +- .../enterprise/blocky/templates/common.yaml | 2 +- .../blocky/templates/prometheusrules.yaml | 18 +++++++++++++ .../blocky/templates/servicemonitor.yaml | 24 +++++++++++++++++ charts/enterprise/blocky/values.yaml | 27 +++++++++++++++++++ 8 files changed, 73 insertions(+), 18 deletions(-) create mode 100644 charts/enterprise/blocky/templates/prometheusrules.yaml create mode 100644 charts/enterprise/blocky/templates/servicemonitor.yaml diff --git a/charts/enterprise/blocky/Chart.yaml b/charts/enterprise/blocky/Chart.yaml index e0ee85d47ff..48e78d35093 100644 --- a/charts/enterprise/blocky/Chart.yaml +++ b/charts/enterprise/blocky/Chart.yaml @@ -26,7 +26,7 @@ sources: - https://github.com/0xERR0R/blocky - https://github.com/Mozart409/blocky-frontend - https://hub.docker.com/r/spx01/blocky -version: 1.0.6 +version: 1.0.7 annotations: truecharts.org/catagories: | - network diff --git a/charts/enterprise/blocky/questions.yaml b/charts/enterprise/blocky/questions.yaml index ddf2f2a2f4f..f54bfe19728 100644 --- a/charts/enterprise/blocky/questions.yaml +++ b/charts/enterprise/blocky/questions.yaml @@ -31,19 +31,6 @@ questions: schema: type: string default: "http://127.0.0.1:4000" - - variable: blocky - group: Container Configuration - label: Blocky Configuration - schema: - additional_attrs: true - type: dict - attrs: - - variable: enablePrometheus - label: Enable Prometheus Endpoint - description: Enables Prometheus Endpoint - schema: - type: boolean - default: true - variable: overrideDefaults group: Container Configuration label: Override Default Upstreams @@ -842,6 +829,7 @@ questions: default: 568 # Include{podSecurityContextAdvanced} # Include{resources} +# Include{metrics} # Include{advanced} # Include{addons} # Include{documentation} diff --git a/charts/enterprise/blocky/templates/_blockyConfig.tpl b/charts/enterprise/blocky/templates/_blockyConfig.tpl index 59153071dd8..dda147e0935 100644 --- a/charts/enterprise/blocky/templates/_blockyConfig.tpl +++ b/charts/enterprise/blocky/templates/_blockyConfig.tpl @@ -22,11 +22,9 @@ redis: required: true connectionAttempts: 10 connectionCooldown: 3s -{{- if .Values.blocky.enablePrometheus }} prometheus: enable: true path: /metrics -{{- end }} upstream: default: {{- .Values.defaultUpstreams | toYaml | nindent 8 }} diff --git a/charts/enterprise/blocky/templates/_webui.tpl b/charts/enterprise/blocky/templates/_webui.tpl index ed7aced8200..4aab724576e 100644 --- a/charts/enterprise/blocky/templates/_webui.tpl +++ b/charts/enterprise/blocky/templates/_webui.tpl @@ -36,12 +36,12 @@ startupProbe: env: - name: NODE_ENV value: "production" +{{- $url := .Values.webUI.apiURL }} {{- if .Values.ingress.main.enabled }} {{- with (first .Values.ingress.main.hosts) }} {{- $url = ( printf "https://%s" .host ) }} {{- end }} {{- else }} -{{- $url = .Values.webUI.apiURL }} {{- end }} - name: API_URL value: "{{ $url }}" diff --git a/charts/enterprise/blocky/templates/common.yaml b/charts/enterprise/blocky/templates/common.yaml index ed83fa6869f..771a3d532ce 100644 --- a/charts/enterprise/blocky/templates/common.yaml +++ b/charts/enterprise/blocky/templates/common.yaml @@ -34,7 +34,7 @@ volumeSpec: {{- $_ := set .Values.podAnnotations "prometheus.io/scrape" "true" -}} {{- $_ := set .Values.podAnnotations "prometheus.io/path" "/metrics" -}} -{{- $_ := set .Values.podAnnotations "prometheus.io/port" (.Values.service.http.ports.http.targetPort | toString) -}} +{{- $_ := set .Values.podAnnotations "prometheus.io/port" (.Values.service.http.ports.http.port | toString) -}} {{- if .Values.webUI.enabled -}} {{- $_ := set .Values.additionalContainers "frontend" (include "blocky.frontend" . | fromYaml) -}} diff --git a/charts/enterprise/blocky/templates/prometheusrules.yaml b/charts/enterprise/blocky/templates/prometheusrules.yaml new file mode 100644 index 00000000000..35b77edf0f6 --- /dev/null +++ b/charts/enterprise/blocky/templates/prometheusrules.yaml @@ -0,0 +1,18 @@ +{{- if and .Values.metrics.enabled .Values.metrics.prometheusRule.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: PrometheusRule +metadata: + name: {{ include "tc.common.names.fullname" . }} + labels: + {{- include "tc.common.labels" . | nindent 4 }} + {{- with .Values.metrics.prometheusRule.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + groups: + - name: {{ include "tc.common.names.fullname" . }} + rules: + {{- with .Values.metrics.prometheusRule.rules }} + {{- toYaml . | nindent 8 }} + {{- end }} +{{- end }} diff --git a/charts/enterprise/blocky/templates/servicemonitor.yaml b/charts/enterprise/blocky/templates/servicemonitor.yaml new file mode 100644 index 00000000000..8b6244bb3a3 --- /dev/null +++ b/charts/enterprise/blocky/templates/servicemonitor.yaml @@ -0,0 +1,24 @@ +{{- if .Values.metrics.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "tc.common.names.fullname" . }} + labels: + {{- include "tc.common.labels" . | nindent 4 }} + {{- with .Values.metrics.serviceMonitor.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + selector: + matchLabels: + {{- include "tc.common.labels.selectorLabels" . | nindent 6 }} + endpoints: + - port: {{ .Values.service.http.ports.http.port }} + {{- with .Values.metrics.serviceMonitor.interval }} + interval: {{ . }} + {{- end }} + {{- with .Values.metrics.serviceMonitor.scrapeTimeout }} + scrapeTimeout: {{ . }} + {{- end }} + path: /metrics +{{- end }} diff --git a/charts/enterprise/blocky/values.yaml b/charts/enterprise/blocky/values.yaml index 1cc95050529..030c56084c0 100644 --- a/charts/enterprise/blocky/values.yaml +++ b/charts/enterprise/blocky/values.yaml @@ -347,6 +347,33 @@ k8sgateway: - name: tls_servername value: cloudflare-dns.com +metrics: + # -- Enable and configure a Prometheus serviceMonitor for the chart under this key. + # @default -- See values.yaml + enabled: false + serviceMonitor: + interval: 1m + scrapeTimeout: 30s + labels: {} + # -- Enable and configure Prometheus Rules for the chart under this key. + # @default -- See values.yaml + prometheusRule: + enabled: false + labels: {} + # -- Configure additionial rules for the chart under this key. + # @default -- See prometheusrules.yaml + rules: + [] + # - alert: UnifiPollerAbsent + # annotations: + # description: Unifi Poller has disappeared from Prometheus service discovery. + # summary: Unifi Poller is down. + # expr: | + # absent(up{job=~".*unifi-poller.*"} == 1) + # for: 5m + # labels: + # severity: critical + redis: enabled: true existingSecret: "rediscreds"