Skip to content

Commit

Permalink
[stable/prometheus-adapter] conditionally register external metrics A…
Browse files Browse the repository at this point in the history
…PI (helm#13716) (helm#14389)

* [stable/prometheus-adapter] conditionally register external metrics API (helm#13716)

The prometheus-adapter will NOT serve external metrics API if
`externalRules` section is not specified. See this code:
https://github.com/DirectXMan12/k8s-prometheus-adapter/blob/v0.5.0/cmd/adapter/adapter.go#L177

In that case, we cannot bindly register the external metrics API.
Otherwise, we might see issues described in helm#13716. This patch fixed the
issue by conditionally register the external metrics API.

Fixes helm#13716

Signed-off-by: Jie Yu <[email protected]>

* [stable/prometheus-adapter] bump chart version to 1.0.3

Bump the chart version to 1.0.3 due to the fix of helm#13716.

Signed-off-by: Jie Yu <[email protected]>

* [stable/prometheus-adapter] use 'and' to combine template directives

To address the review comments.

Signed-off-by: Jie Yu <[email protected]>

* [stable/prometheus-adapter] add ci test values

To improve the test coverage.

Signed-off-by: Jie Yu <[email protected]>
  • Loading branch information
jieyu authored and k8s-ci-robot committed Jun 2, 2019
1 parent fd7ace6 commit 87c90e6
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion stable/prometheus-adapter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
name: prometheus-adapter
version: 1.0.2
version: 1.0.3
appVersion: v0.5.0
description: A Helm chart for k8s prometheus adapter
home: https://github.com/DirectXMan12/k8s-prometheus-adapter
Expand Down
Empty file.
9 changes: 9 additions & 0 deletions stable/prometheus-adapter/ci/external-rules-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
rules:
external:
- seriesQuery: '{__name__=~"^some_metric_count$"}'
resources:
template: <<.Resource>>
name:
matches: ""
as: "my_custom_metric"
metricsQuery: sum(<<.Series>>{<<.LabelMatchers>>}) by (<<.GroupBy>>)
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if .Values.rules.external }}
apiVersion: apiregistration.k8s.io/v1beta1
kind: APIService
metadata:
Expand All @@ -19,3 +20,4 @@ spec:
insecureSkipTLSVerify: {{ if .Values.tls.enable }}false{{ else }}true{{ end }}
groupPriorityMinimum: 100
versionPriority: 100
{{- end -}}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.rbac.create -}}
{{- if and .Values.rbac.create .Values.rules.external -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

{{- if .Values.rbac.create -}}
{{- if and .Values.rbac.create .Values.rules.external -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
Expand Down

0 comments on commit 87c90e6

Please sign in to comment.