From ab753b47fbba371e6b20128b98cbf27d4a522d75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Sun, 12 Nov 2023 17:36:18 +0100 Subject: [PATCH 1/8] helm: Enrich serviceMonitor properties MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan-Otto Kröpke --- helm/oauth2-proxy/Chart.yaml | 2 +- .../ci/servicemonitor-values.yaml | 14 +++++++++ .../templates/servicemonitor.yaml | 30 +++++++++++++++++-- helm/oauth2-proxy/values.yaml | 23 ++++++++++++++ 4 files changed, 66 insertions(+), 3 deletions(-) diff --git a/helm/oauth2-proxy/Chart.yaml b/helm/oauth2-proxy/Chart.yaml index 898e1594..4b53b96d 100644 --- a/helm/oauth2-proxy/Chart.yaml +++ b/helm/oauth2-proxy/Chart.yaml @@ -1,5 +1,5 @@ name: oauth2-proxy -version: 6.18.1 +version: 6.18.2 apiVersion: v2 appVersion: 7.5.1 home: https://oauth2-proxy.github.io/oauth2-proxy/ diff --git a/helm/oauth2-proxy/ci/servicemonitor-values.yaml b/helm/oauth2-proxy/ci/servicemonitor-values.yaml index 9d31c285..0c232bf5 100644 --- a/helm/oauth2-proxy/ci/servicemonitor-values.yaml +++ b/helm/oauth2-proxy/ci/servicemonitor-values.yaml @@ -2,3 +2,17 @@ metrics: enabled: true serviceMonitor: enabled: true + annotations: + key: value + metricRelabelings: + - action: keep + regex: 'kube_(daemonset|deployment|pod|namespace|node|statefulset).+' + sourceLabels: [__name__] + + relabelings: + - sourceLabels: [__meta_kubernetes_pod_node_name] + separator: ; + regex: ^(.*)$ + targetLabel: nodename + replacement: $1 + action: replace diff --git a/helm/oauth2-proxy/templates/servicemonitor.yaml b/helm/oauth2-proxy/templates/servicemonitor.yaml index 1a2dbce1..269e7ce5 100644 --- a/helm/oauth2-proxy/templates/servicemonitor.yaml +++ b/helm/oauth2-proxy/templates/servicemonitor.yaml @@ -2,6 +2,10 @@ apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: + {{- with .Values.metrics.serviceMonitor.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} name: {{ template "oauth2-proxy.fullname" . }} {{- if .Values.metrics.servicemonitor.namespace }} namespace: {{ .Values.metrics.servicemonitor.namespace }} @@ -26,6 +30,28 @@ spec: endpoints: - port: metrics path: "/metrics" - interval: {{ .Values.metrics.servicemonitor.interval }} - scrapeTimeout: {{ .Values.metrics.servicemonitor.scrapeTimeout }} + {{- with .Values.metrics.serviceMonitor.interval }} + interval: {{ . }} + {{- end }} + {{- with .Values.metrics.serviceMonitor.scrapeTimeout }} + scrapeTimeout: {{ . }} + {{- end }} + {{- with .Values.metrics.serviceMonitor.scheme }} + scheme: {{ . }} + {{- end }} + {{- with .Values.metrics.serviceMonitor.bearerTokenFile }} + bearerTokenFile: {{ . }} + {{- end }} + {{- with .Values.metrics.serviceMonitor.tlsConfig }} + tlsConfig: + {{- toYaml .| nindent 8 }} + {{- end }} + {{- with .Values.metrics.serviceMonitor.metricRelabelings }} + metricRelabelings: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.metrics.serviceMonitor.relabelings }} + relabelings: + {{- toYaml . | nindent 8 }} + {{- end }} {{- end }} diff --git a/helm/oauth2-proxy/values.yaml b/helm/oauth2-proxy/values.yaml index 8d73d27d..b52c6922 100644 --- a/helm/oauth2-proxy/values.yaml +++ b/helm/oauth2-proxy/values.yaml @@ -373,6 +373,29 @@ metrics: # Add custom labels to the ServiceMonitor resource labels: {} + ## Used to pass annotations that are used by the Prometheus installed in your cluster to select Service Monitors to work with + ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#prometheusspec + annotations: {} + + ## Metric relabel configs to apply to samples before ingestion. + ## [Metric Relabeling](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#metric_relabel_configs) + metricRelabelings: [] + # - action: keep + # regex: 'kube_(daemonset|deployment|pod|namespace|node|statefulset).+' + # sourceLabels: [__name__] + + ## Relabel configs to apply to samples before ingestion. + ## [Relabeling](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config) + relabelings: [] + # - sourceLabels: [__meta_kubernetes_pod_node_name] + # separator: ; + # regex: ^(.*)$ + # targetLabel: nodename + # replacement: $1 + # action: replace + + targetLabels: [] + # Extra K8s manifests to deploy extraObjects: [] # - apiVersion: secrets-store.csi.x-k8s.io/v1 From 8d90ab3595199ba856cab447e60ee6735c1aca0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Mon, 13 Nov 2023 11:19:10 +0100 Subject: [PATCH 2/8] adjust changelog --- helm/oauth2-proxy/Chart.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helm/oauth2-proxy/Chart.yaml b/helm/oauth2-proxy/Chart.yaml index 4b53b96d..31e8bae0 100644 --- a/helm/oauth2-proxy/Chart.yaml +++ b/helm/oauth2-proxy/Chart.yaml @@ -35,7 +35,7 @@ kubeVersion: ">=1.9.0-0" annotations: artifacthub.io/changes: | - kind: added - description: Define image repository & pullPolicy on the initContainer wait-for-redis + description: Make serviceMonitor.scheme,serviceMonitor.bearerTokenFile,serviceMonitor.tlsConfig,serviceMonitor.targetLabels configurable links: - name: Github PR - url: https://github.com/oauth2-proxy/manifests/pull/166 + url: https://github.com/oauth2-proxy/manifests/pull/170 From bcf40ec750d111cf749d76b9b3ca6a8903dd9ff5 Mon Sep 17 00:00:00 2001 From: Pierluigi Lenoci Date: Mon, 13 Nov 2023 12:03:40 +0100 Subject: [PATCH 3/8] Update Chart.yaml --- helm/oauth2-proxy/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/oauth2-proxy/Chart.yaml b/helm/oauth2-proxy/Chart.yaml index 31e8bae0..0a2a1ceb 100644 --- a/helm/oauth2-proxy/Chart.yaml +++ b/helm/oauth2-proxy/Chart.yaml @@ -1,5 +1,5 @@ name: oauth2-proxy -version: 6.18.2 +version: 6.18.3 apiVersion: v2 appVersion: 7.5.1 home: https://oauth2-proxy.github.io/oauth2-proxy/ From 9c4af9475beb28d85e8e68205d66b60d24ceab8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Mon, 13 Nov 2023 12:42:00 +0100 Subject: [PATCH 4/8] Adjust indent and serviceMonitor -> servicemonitor --- helm/oauth2-proxy/Chart.lock | 6 ++--- .../ci/servicemonitor-values.yaml | 2 +- .../templates/servicemonitor.yaml | 22 +++++++++---------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/helm/oauth2-proxy/Chart.lock b/helm/oauth2-proxy/Chart.lock index ba7fc184..ff0a5fa0 100644 --- a/helm/oauth2-proxy/Chart.lock +++ b/helm/oauth2-proxy/Chart.lock @@ -1,6 +1,6 @@ dependencies: - name: redis repository: https://charts.bitnami.com/bitnami - version: 18.1.5 -digest: sha256:1b36e81e2d34a33ba7aa2229bfe6216ace85789aea70f9c2d72c59d58f3a2b4f -generated: "2023-10-17T15:27:08.54732+02:00" + version: 18.1.6 +digest: sha256:7f2a388e0e822328364d22242f5a20fe3e7fd9859240e490b1075982cb921152 +generated: "2023-11-13T12:39:20.523433+01:00" diff --git a/helm/oauth2-proxy/ci/servicemonitor-values.yaml b/helm/oauth2-proxy/ci/servicemonitor-values.yaml index 0c232bf5..b2395bb8 100644 --- a/helm/oauth2-proxy/ci/servicemonitor-values.yaml +++ b/helm/oauth2-proxy/ci/servicemonitor-values.yaml @@ -1,6 +1,6 @@ metrics: enabled: true - serviceMonitor: + servicemonitor: enabled: true annotations: key: value diff --git a/helm/oauth2-proxy/templates/servicemonitor.yaml b/helm/oauth2-proxy/templates/servicemonitor.yaml index cb360f95..a3493737 100644 --- a/helm/oauth2-proxy/templates/servicemonitor.yaml +++ b/helm/oauth2-proxy/templates/servicemonitor.yaml @@ -2,7 +2,7 @@ apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: - {{- with .Values.metrics.serviceMonitor.annotations }} + {{- with .Values.metrics.servicemonitor.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} @@ -30,28 +30,28 @@ spec: endpoints: - port: metrics path: "/metrics" - {{- with .Values.metrics.serviceMonitor.interval }} + {{- with .Values.metrics.servicemonitor.interval }} interval: {{ . }} {{- end }} - {{- with .Values.metrics.serviceMonitor.scrapeTimeout }} + {{- with .Values.metrics.servicemonitor.scrapeTimeout }} scrapeTimeout: {{ . }} {{- end }} - {{- with .Values.metrics.serviceMonitor.scheme }} + {{- with .Values.metrics.servicemonitor.scheme }} scheme: {{ . }} {{- end }} - {{- with .Values.metrics.serviceMonitor.bearerTokenFile }} + {{- with .Values.metrics.servicemonitor.bearerTokenFile }} bearerTokenFile: {{ . }} {{- end }} - {{- with .Values.metrics.serviceMonitor.tlsConfig }} + {{- with .Values.metrics.servicemonitor.tlsConfig }} tlsConfig: - {{- toYaml .| nindent 8 }} + {{- toYaml .| nindent 4 }} {{- end }} - {{- with .Values.metrics.serviceMonitor.metricRelabelings }} + {{- with .Values.metrics.servicemonitor.metricRelabelings }} metricRelabelings: - {{- toYaml . | nindent 8 }} + {{- toYaml . | nindent 4 }} {{- end }} - {{- with .Values.metrics.serviceMonitor.relabelings }} + {{- with .Values.metrics.servicemonitor.relabelings }} relabelings: - {{- toYaml . | nindent 8 }} + {{- toYaml . | nindent 4 }} {{- end }} {{- end }} From 523b5201d9e2b5717098ed4c7c81a1cb22cdc6ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Mon, 13 Nov 2023 12:49:21 +0100 Subject: [PATCH 5/8] Add docs --- helm/oauth2-proxy/README.md | 7 +++++++ helm/oauth2-proxy/values.yaml | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/helm/oauth2-proxy/README.md b/helm/oauth2-proxy/README.md index 1cfe0af5..f6a6a0c2 100644 --- a/helm/oauth2-proxy/README.md +++ b/helm/oauth2-proxy/README.md @@ -207,6 +207,13 @@ Parameter | Description | Default `metrics.serviceMonitor.interval` | Prometheus scrape interval | `60s` `metrics.serviceMonitor.scrapeTimeout` | Prometheus scrape timeout | `30s` `metrics.serviceMonitor.labels` | Add custom labels to the ServiceMonitor resource| `{}` +`metrics.serviceMonitor.scheme` | HTTP scheme to use for scraping. Can be used with `tlsConfig` for example if using istio mTLS.| `""` +`metrics.serviceMonitor.tlsConfig` | TLS configuration to use when scraping the endpoint. For example if using istio mTLS.| `{}` +`metrics.serviceMonitor.bearerTokenFile` | Path to bearer token file.| `""` +`metrics.serviceMonitor.annotations` | Used to pass annotations that are used by the Prometheus installed in your cluster| `{}` +`metrics.serviceMonitor.metricRelabelings` | Metric relabel configs to apply to samples before ingestion.| `[]` +`metrics.serviceMonitor.relabelings` | Relabel configs to apply to samples before ingestion.| `[]` +`metrics.serviceMonitor.targetLabels` | Attach labels to the ServiceMonitor resource based on Service metadata.| `[]` `extraObjects` | Extra K8s manifests to deploy | `[]` Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, diff --git a/helm/oauth2-proxy/values.yaml b/helm/oauth2-proxy/values.yaml index 144487df..f255edbe 100644 --- a/helm/oauth2-proxy/values.yaml +++ b/helm/oauth2-proxy/values.yaml @@ -373,6 +373,16 @@ metrics: # Add custom labels to the ServiceMonitor resource labels: {} + ## scheme: HTTP scheme to use for scraping. Can be used with `tlsConfig` for example if using istio mTLS. + scheme: "" + + ## tlsConfig: TLS configuration to use when scraping the endpoint. For example if using istio mTLS. + ## Of type: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#tlsconfig + tlsConfig: {} + + ## bearerTokenFile: Path to bearer token file. + bearerTokenFile: "" + ## Used to pass annotations that are used by the Prometheus installed in your cluster to select Service Monitors to work with ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#prometheusspec annotations: {} @@ -394,6 +404,7 @@ metrics: # replacement: $1 # action: replace + ## Attach labels to the ServiceMonitor resource based on Service metadata. targetLabels: [] # Extra K8s manifests to deploy From 06551ac811c28188eb519a5b735c7d65ea355d5f Mon Sep 17 00:00:00 2001 From: Pierluigi Lenoci Date: Mon, 13 Nov 2023 13:02:07 +0100 Subject: [PATCH 6/8] Update Chart.yaml --- helm/oauth2-proxy/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/oauth2-proxy/Chart.yaml b/helm/oauth2-proxy/Chart.yaml index 7d8803b6..2454cf89 100644 --- a/helm/oauth2-proxy/Chart.yaml +++ b/helm/oauth2-proxy/Chart.yaml @@ -1,5 +1,5 @@ name: oauth2-proxy -version: 6.18.3 +version: 6.18.4 apiVersion: v2 appVersion: 7.5.1 home: https://oauth2-proxy.github.io/oauth2-proxy/ From 95a6629de7197ddf13c8559e5353c4b030df86b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Mon, 13 Nov 2023 14:59:02 +0100 Subject: [PATCH 7/8] Add suggestions from code review. --- helm/oauth2-proxy/README.md | 1 - helm/oauth2-proxy/ci/servicemonitor-values.yaml | 2 +- helm/oauth2-proxy/templates/servicemonitor.yaml | 16 ++++++++-------- helm/oauth2-proxy/values.yaml | 3 --- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/helm/oauth2-proxy/README.md b/helm/oauth2-proxy/README.md index f6a6a0c2..ff02c754 100644 --- a/helm/oauth2-proxy/README.md +++ b/helm/oauth2-proxy/README.md @@ -213,7 +213,6 @@ Parameter | Description | Default `metrics.serviceMonitor.annotations` | Used to pass annotations that are used by the Prometheus installed in your cluster| `{}` `metrics.serviceMonitor.metricRelabelings` | Metric relabel configs to apply to samples before ingestion.| `[]` `metrics.serviceMonitor.relabelings` | Relabel configs to apply to samples before ingestion.| `[]` -`metrics.serviceMonitor.targetLabels` | Attach labels to the ServiceMonitor resource based on Service metadata.| `[]` `extraObjects` | Extra K8s manifests to deploy | `[]` Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, diff --git a/helm/oauth2-proxy/ci/servicemonitor-values.yaml b/helm/oauth2-proxy/ci/servicemonitor-values.yaml index b2395bb8..0c232bf5 100644 --- a/helm/oauth2-proxy/ci/servicemonitor-values.yaml +++ b/helm/oauth2-proxy/ci/servicemonitor-values.yaml @@ -1,6 +1,6 @@ metrics: enabled: true - servicemonitor: + serviceMonitor: enabled: true annotations: key: value diff --git a/helm/oauth2-proxy/templates/servicemonitor.yaml b/helm/oauth2-proxy/templates/servicemonitor.yaml index a3493737..bfb3084b 100644 --- a/helm/oauth2-proxy/templates/servicemonitor.yaml +++ b/helm/oauth2-proxy/templates/servicemonitor.yaml @@ -2,7 +2,7 @@ apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: - {{- with .Values.metrics.servicemonitor.annotations }} + {{- with .Values.metrics.serviceMonitor.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} @@ -30,27 +30,27 @@ spec: endpoints: - port: metrics path: "/metrics" - {{- with .Values.metrics.servicemonitor.interval }} + {{- with .Values.metrics.serviceMonitor.interval }} interval: {{ . }} {{- end }} - {{- with .Values.metrics.servicemonitor.scrapeTimeout }} + {{- with .Values.metrics.serviceMonitor.scrapeTimeout }} scrapeTimeout: {{ . }} {{- end }} - {{- with .Values.metrics.servicemonitor.scheme }} + {{- with .Values.metrics.serviceMonitor.scheme }} scheme: {{ . }} {{- end }} - {{- with .Values.metrics.servicemonitor.bearerTokenFile }} + {{- with .Values.metrics.serviceMonitor.bearerTokenFile }} bearerTokenFile: {{ . }} {{- end }} - {{- with .Values.metrics.servicemonitor.tlsConfig }} + {{- with .Values.metrics.serviceMonitor.tlsConfig }} tlsConfig: {{- toYaml .| nindent 4 }} {{- end }} - {{- with .Values.metrics.servicemonitor.metricRelabelings }} + {{- with .Values.metrics.serviceMonitor.metricRelabelings }} metricRelabelings: {{- toYaml . | nindent 4 }} {{- end }} - {{- with .Values.metrics.servicemonitor.relabelings }} + {{- with .Values.metrics.serviceMonitor.relabelings }} relabelings: {{- toYaml . | nindent 4 }} {{- end }} diff --git a/helm/oauth2-proxy/values.yaml b/helm/oauth2-proxy/values.yaml index f255edbe..9c3ee0e7 100644 --- a/helm/oauth2-proxy/values.yaml +++ b/helm/oauth2-proxy/values.yaml @@ -404,9 +404,6 @@ metrics: # replacement: $1 # action: replace - ## Attach labels to the ServiceMonitor resource based on Service metadata. - targetLabels: [] - # Extra K8s manifests to deploy extraObjects: [] # - apiVersion: secrets-store.csi.x-k8s.io/v1 From 0558cfba58cb876608e4ec77012186229a724165 Mon Sep 17 00:00:00 2001 From: Pierluigi Lenoci Date: Mon, 13 Nov 2023 16:07:14 +0100 Subject: [PATCH 8/8] Update Chart.yaml --- helm/oauth2-proxy/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/oauth2-proxy/Chart.yaml b/helm/oauth2-proxy/Chart.yaml index 2454cf89..ce3cab8d 100644 --- a/helm/oauth2-proxy/Chart.yaml +++ b/helm/oauth2-proxy/Chart.yaml @@ -1,5 +1,5 @@ name: oauth2-proxy -version: 6.18.4 +version: 6.19.0 apiVersion: v2 appVersion: 7.5.1 home: https://oauth2-proxy.github.io/oauth2-proxy/