Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ add support for OpenTelemetry and Traefik v3 #760

Merged
merged 1 commit into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion traefik/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


Traefik Proxy {{ .Chart.AppVersion }} has been deployed successfully
Traefik Proxy {{ .Values.image.tag | default .Chart.AppVersion }} has been deployed successfully
on {{ template "traefik.namespace" . }} namespace !

{{- if .Values.hub.enabled }}
Expand Down
55 changes: 55 additions & 0 deletions traefik/templates/_podtemplate.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
{{- end }}
- "--api.dashboard=true"
- "--ping=true"

{{- if .Values.metrics }}
{{- with .Values.metrics.datadog }}
- "--metrics.datadog=true"
Expand All @@ -143,6 +144,7 @@
- "--metrics.datadog.addServicesLabels=false"
{{- end }}
{{- end }}

{{- with .Values.metrics.influxdb }}
- "--metrics.influxdb=true"
- "--metrics.influxdb.address={{ .address }}"
Expand Down Expand Up @@ -175,6 +177,7 @@
- "--metrics.influxdb.addServicesLabels=false"
{{- end }}
{{- end }}

{{- with .Values.metrics.influxdb2 }}
- "--metrics.influxdb2=true"
- "--metrics.influxdb2.address={{ .address }}"
Expand Down Expand Up @@ -238,6 +241,58 @@
{{- end }}

{{- end }}

{{- with .Values.metrics.openTelemetry }}
{{- if eq ($.Values.experimental.v3.enabled | toString) "false" }}
{{- fail "ERROR: OpenTelemetry features are only available on Traefik v3. Please set `experimental.v3.enabled` to true and update `image.tag` to `v3.0`." }}
{{- end }}
- "--metrics.openTelemetry=true"
- "--metrics.openTelemetry.address={{ .address }}"
{{- with .addEntryPointsLabels }}
- "--metrics.openTelemetry.addEntryPointsLabels={{ . }}"
{{- end }}
{{- with .addRoutersLabels }}
- "--metrics.openTelemetry.addRoutersLabels={{ . }}"
{{- end }}
{{- with .addServicesLabels }}
- "--metrics.openTelemetry.addServicesLabels={{ . }}"
{{- end }}
{{- with .explicitBoundaries }}
- "--metrics.openTelemetry.explicitBoundaries={{ join "," . }}"
{{- end }}
{{- with .headers }}
{{- range $name, $value := . }}
- "--metrics.openTelemetry.headers.{{ $name }}={{ $value }}"
{{- end }}
{{- end }}
{{- with .insecure }}
- "--metrics.openTelemetry.insecure={{ . }}"
{{- end }}
{{- with .pushInterval }}
- "--metrics.openTelemetry.pushInterval={{ . }}"
{{- end }}
{{- with .path }}
- "--metrics.openTelemetry.path={{ . }}"
{{- end }}
{{- with .tls }}
{{- with .ca }}
- "--metrics.openTelemetry.tls.ca={{ . }}"
{{- end }}
{{- with .cert }}
- "--metrics.openTelemetry.tls.cert={{ . }}"
{{- end }}
{{- with .key }}
- "--metrics.openTelemetry.tls.key={{ . }}"
{{- end }}
{{- with .insecureSkipVerify }}
- "--metrics.openTelemetry.tls.insecureSkipVerify={{ . }}"
{{- end }}
{{- end }}
{{- with .grpc }}
- "--metrics.openTelemetry.grpc={{ . }}"
{{- end }}
{{- end }}

{{- if .Values.tracing }}
{{- if .Values.tracing.instana }}
- "--tracing.instana=true"
Expand Down
85 changes: 85 additions & 0 deletions traefik/tests/metrics-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@ suite: Traefik Metrics configuration
templates:
- deployment.yaml
tests:
- it: should set default values for args
asserts:
- equal:
path: spec.template.spec.containers[0].args
value:
- --global.checknewversion
- --global.sendanonymoususage
- --entrypoints.metrics.address=:9100/tcp
- --entrypoints.traefik.address=:9000/tcp
- --entrypoints.web.address=:8000/tcp
- --entrypoints.websecure.address=:8443/tcp
- --api.dashboard=true
- --ping=true
- --metrics.prometheus=true
- --metrics.prometheus.entrypoint=metrics
- --providers.kubernetescrd
- --providers.kubernetesingress
- --entrypoints.websecure.http.tls=true

- it: "should support to set prometheus: null"
set:
metrics:
Expand Down Expand Up @@ -269,3 +288,69 @@ tests:
path: spec.template.spec.containers[0].args
content: "--metrics.statsd.addRoutersLabels=true"

- it: should be possible to set specific parameters on openTelemetry
set:
experimental:
v3:
enabled: true
metrics:
openTelemetry:
address: "localhost:4318"
addEntryPointsLabels: true
addRoutersLabels: true
addServicesLabels: true
explicitBoundaries:
- "0.1"
- "0.3"
- "1.2"
- "5.0"
headers:
foo: bar
test: test
insecure: true
pushInterval: 10s
path: /foo/v1/traces
tls:
ca: path/to/ca.crt
cert: path/to/foo.cert
key: path/to/key.key
insecureSkipVerify: true
grpc: true
asserts:
- contains:
path: spec.template.spec.containers[0].args
content: "--metrics.openTelemetry=true"
- contains:
path: spec.template.spec.containers[0].args
content: "--metrics.openTelemetry.address=localhost:4318"
- contains:
path: spec.template.spec.containers[0].args
content: "--metrics.openTelemetry.addEntryPointsLabels=true"
- contains:
path: spec.template.spec.containers[0].args
content: "--metrics.openTelemetry.addRoutersLabels=true"
- contains:
path: spec.template.spec.containers[0].args
content: "--metrics.openTelemetry.addServicesLabels=true"
- contains:
path: spec.template.spec.containers[0].args
content: "--metrics.openTelemetry.explicitBoundaries=0.1,0.3,1.2,5.0"
- contains:
path: spec.template.spec.containers[0].args
content: "--metrics.openTelemetry.headers.foo=bar"
- contains:
path: spec.template.spec.containers[0].args
content: "--metrics.openTelemetry.headers.test=test"

- it: should throw and error when open telemetry is enabled without traefik v3
set:
experimental:
v3:
enabled: false
metrics:
openTelemetry:
address: "localhost:4318"
addEntryPointsLabels: true
asserts:
- failedTemplate:
errorMessage: "OpenTelemetry features are only available on Traefik v3. Please set `experimental.v3.enabled` to true and update `image.tag` to `v3.0`."
13 changes: 13 additions & 0 deletions traefik/tests/notes_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,16 @@ tests:
--set tunnelDeployment.traefik.tunnelPort=9901

See https://doc.traefik.io/traefik-hub/install/#traefik-hub-agent-install-with-helmchart

- it: should use tag version in release notes output if set
set:
image:
tag: v3.0
asserts:
- equal:
path: raw
value: |


Traefik Proxy v3.0 has been deployed successfully
on NAMESPACE namespace !
40 changes: 39 additions & 1 deletion traefik/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ ingressClass:

# Enable experimental features
experimental:
v3:
enabled: false
plugins:
enabled: false
kubernetesGateway:
Expand Down Expand Up @@ -347,7 +349,43 @@ metrics:
# # addRoutersLabels: true
# ## Enable metrics on services. Default=true
# # addServicesLabels: false

# openTelemetry:
# ## Address of the OpenTelemetry Collector to send metrics to.
# address: "localhost:4318"
# ## Enable metrics on entry points.
# addEntryPointsLabels: true
# ## Enable metrics on routers.
# addRoutersLabels: true
# ## Enable metrics on services.
# addServicesLabels: true
# ## Explicit boundaries for Histogram data points.
# explicitBoundaries:
# - "0.1"
# - "0.3"
# - "1.2"
# - "5.0"
# ## Additional headers sent with metrics by the reporter to the OpenTelemetry Collector.
# headers:
# foo: bar
# test: test
# ## Allows reporter to send metrics to the OpenTelemetry Collector without using a secured protocol.
# insecure: true
# ## Interval at which metrics are sent to the OpenTelemetry Collector.
# pushInterval: 10s
# ## Allows to override the default URL path used for sending metrics. This option has no effect when using gRPC transport.
# path: /foo/v1/traces
# ## Defines the TLS configuration used by the reporter to send metrics to the OpenTelemetry Collector.
# tls:
# ## The path to the certificate authority, it defaults to the system bundle.
# ca: path/to/ca.crt
# ## The path to the public certificate. When using this option, setting the key option is required.
# cert: path/to/foo.cert
# ## The path to the private key. When using this option, setting the cert option is required.
# key: path/to/key.key
# ## If set to true, the TLS connection accepts any certificate presented by the server regardless of the hostnames it covers.
# insecureSkipVerify: true
# ## This instructs the reporter to send metrics to the OpenTelemetry Collector using gRPC.
# grpc: true

##
## enable optional CRDs for Prometheus Operator
Expand Down