Traefik opentelemetry

@tommoulard I am trying to deploy this in my k8 cluster where otel collector is running like a daemonset, not sure how to pass in the node ip to the command line args ?

  --tracing.openTelemetry.grpc=true
  --tracing.openTelemetry.address=${HOST_IP}:4317
  --tracing.openTelemetry.insecure=true

also if we are using aws xray as tracing backend, how can we change the trace id to xray specific ID ? for instance in our downstream services we use @opentelemetry/id-generator-aws-xray - npm

Hello @jayasai470 and thanks for your interest in Traefik,

To pass the node IP in the command line, you have to use the Downward API. It should be something like that for your use case:

args:
  - --tracing.openTelemetry.grpc=true
  - --tracing.openTelemetry.insecure=true
  - --tracing.openTelemetry.address=$(HOST_IP):4317
env:
  - name: HOST_IP
    valueFrom:
      fieldRef:
        fieldPath: status.hostIP

For your second point, AWS XRay is currently not supported in Traefik. Feel free to open a feature request to support AWSXray ID Generator.

1 Like

Thanks for your response, I have already tried downward api but this does not replace $(HOST_IP) in the container

Hi @jayasai470,

I just tried again the downward API and everything is working as expected. With the following deployment, in the Traefik I can see that it is trying to connect to the HOST_IP.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: traefik

spec:
  selector:
    matchLabels:
      app: traefik

  template:
    metadata:
      labels:
        app: traefik

    spec:
      serviceAccountName: traefik-ingress-controller
      containers:
        - name: traefik
          image: traefik:v3.0
          ports:
            - containerPort: 80
              name: http

            - containerPort: 443
              name: https

            - containerPort: 3000
              name: tcp

            - containerPort: 8080
              name: api

          env:
            - name: HOST_IP
              valueFrom:
                fieldRef:
                  fieldPath: status.hostIP

          args:
            - --api.insecure=true
            - --log.level=debug
            - --log.format=json
            - --entrypoints.http.address=:8000
            - --entrypoints.https.address=:8443
            - --entrypoints.https.http.tls=true
            - --providers.kubernetesIngress
            - --tracing.openTelemetry.grpc=true
            - --tracing.openTelemetry.address=$(HOST_IP):4317
            - --tracing.openTelemetry.insecure=true

Here is my node IP:

NAME                       STATUS   ROLES                  AGE     VERSION        INTERNAL-IP   EXTERNAL-IP   OS-IMAGE   KERNEL-VERSION     CONTAINER-RUNTIME
k3d-traefik-k8s-server-0   Ready    control-plane,master   4m47s   v1.23.6+k3s1   172.27.0.3    <none>        K3s dev    5.15.49-linuxkit   containerd://1.5.11-k3s2
k3d-traefik-k8s-agent-0    Ready    <none>                 4m40s   v1.23.6+k3s1   172.27.0.4    <none>        K3s dev    5.15.49-linuxkit   containerd://1.5.11-k3s2
k3d-traefik-k8s-agent-1    Ready    <none>                 4m40s   v1.23.6+k3s1   172.27.0.5    <none>        K3s dev    5.15.49-linuxkit   containerd://1.5.11-k3s2

And here is the log output (I do not have a running collector):

2023/01/10 13:17:30 max retry time elapsed: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing dial tcp 172.27.0.4:4317: connect: connection refused"

What is the error in the logs?
Have you properly configured the daemonset to make it reachable at the HOST_IP?