-
Notifications
You must be signed in to change notification settings - Fork 762
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add (optional) dedicated metrics service (#727)
Signed-off-by: Freddy Grieshaber <[email protected]> Co-authored-by: Michel Loiseleur <[email protected]>
- Loading branch information
1 parent
f4a7bec
commit 498a645
Showing
9 changed files
with
190 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ apiVersion: v2 | |
name: traefik | ||
description: A Traefik based Kubernetes ingress controller | ||
type: application | ||
version: 20.3.1 | ||
version: 20.4.0 | ||
appVersion: v2.9.4 | ||
keywords: | ||
- traefik | ||
|
@@ -24,6 +24,5 @@ maintainers: | |
email: [email protected] | ||
icon: https://raw.githubusercontent.com/traefik/traefik/v2.3/docs/content/assets/img/traefik.logo.png | ||
annotations: | ||
artifacthub.io/changes: "- Adds support for namespace overrides in subchart use\n- Document recent changes in the README (#717)\n" | ||
artifacthub.io/changes: | | ||
- 🐛 Fix namespace override which was missing on `ServiceAccount` | ||
- Add (optional) dedicated metrics service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{{- define "traefik.metrics-service-metadata" }} | ||
labels: | ||
{{- include "traefik.metricsservicelabels" . | nindent 4 -}} | ||
{{- with .Values.metrics.prometheus.service.labels }} | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* Labels used for metrics-relevant selector*/}} | ||
{{/* This is an immutable field: this should not change between upgrade */}} | ||
{{- define "traefik.metricslabelselector" -}} | ||
{{- include "traefik.labelselector" . }} | ||
app.kubernetes.io/component: metrics | ||
{{- end }} | ||
|
||
{{/* Shared labels used in metadata of metrics-service and servicemonitor */}} | ||
{{- define "traefik.metricsservicelabels" -}} | ||
{{ include "traefik.metricslabelselector" . }} | ||
helm.sh/chart: {{ template "traefik.chart" . }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{{- $fullname := include "traefik.fullname" . }} | ||
{{- if ge (len $fullname) 50 }} | ||
{{- fail "ERROR: Cannot create a metrics service when name contains more than 50 characters" }} | ||
{{- end }} | ||
|
||
{{- if (and (.Values.metrics.prometheus.service).enabled (not .Values.hub.enabled)) -}} | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ $fullname }}-metrics | ||
namespace: {{ template "traefik.namespace" . }} | ||
{{- template "traefik.metrics-service-metadata" . }} | ||
annotations: | ||
{{- with .Values.metrics.prometheus.service.annotations }} | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
spec: | ||
type: ClusterIP | ||
selector: | ||
{{- include "traefik.labelselector" . | nindent 4 }} | ||
ports: | ||
- port: {{ .Values.ports.metrics.port }} | ||
name: "metrics" | ||
targetPort: metrics | ||
protocol: TCP | ||
{{- if .Values.ports.metrics.nodePort }} | ||
nodePort: {{ .Values.ports.metrics.nodePort }} | ||
{{- end }} | ||
{{- end -}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
suite: Metrics Service configuration | ||
templates: | ||
- service-metrics.yaml | ||
tests: | ||
- it: should not provide a dedicated metrics service by default | ||
asserts: | ||
- hasDocuments: | ||
count: 0 | ||
- it: should not provide a dedicated metrics service when hub is enabled | ||
set: | ||
hub: | ||
enabled: true | ||
metrics: | ||
prometheus: | ||
service: | ||
enabled: true | ||
asserts: | ||
- hasDocuments: | ||
count: 0 | ||
- it: should provide a dedicated metrics service when enabled set to true | ||
set: | ||
metrics: | ||
prometheus: | ||
service: | ||
enabled: true | ||
labels: | ||
custom-label: label-value | ||
annotations: | ||
custom-annotation: annotation-value | ||
asserts: | ||
- hasDocuments: | ||
count: 1 | ||
- equal: | ||
path: spec.type | ||
value: ClusterIP | ||
- equal: | ||
path: metadata.labels.custom-label | ||
value: label-value | ||
- equal: | ||
path: metadata.annotations.custom-annotation | ||
value: annotation-value | ||
- equal: | ||
path: spec.selector | ||
value: | ||
app.kubernetes.io/name: traefik | ||
app.kubernetes.io/instance: RELEASE-NAME-NAMESPACE | ||
- contains: | ||
path: spec.ports | ||
content: | ||
port: 9100 | ||
name: "metrics" | ||
targetPort: metrics | ||
protocol: TCP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters