Opentracing plugin is not usable in Kubernetes
Is there an existing issue for this?
- [X] I have searched the existing issues
Kong version ($ kong version)
3.1.x
Current Behavior
TLDR: Datadog plugin config ( read config from env variable) is capable of hosted in k8s, similar functionality doesn't exist for Opentracing.
The reason this is a bug not enhancement is because plugin documentation says Kubernetes is supported. It looks like OpenTracing is not designed to work with Kubernetes. Basically, Following diagram is the usage of the Opentracing, OpenTracing uses the endpoint to send traces to OT Collector that sits on the same machine/KubeNode. Please note that we want to reach OT Collector that runs on the same host not run OT Collector as service which will be Load balanced across the cluster.
In this Kong Channel video, It uses Docker Hostname but the same functionality doesn't exist in k8s, and we meant to use status.hostIP which can only be used as env variable.
KubeNode
+------------------------------------+
| |
| Kong OT -> OT collector |
| |
+------------------------------------+
In KongClusterPlugin's Yaml file: Endpoint's required to be hardcoded. It doesn't accept environment variable. What's needed is to be able to reach hostIP, but there is no way to read that.
config:
endpoint: http://opentracingcollector:4318/v1/traces
In Kubernetes We can set hostIP as environment variable to Kong in which plugin runs.
host_ip:
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.hostIP
Expected Behavior
Plugin Config should accept environment variables set in the plugin kong process/container ( not k8s terminology). This is so that, environment variable will be replaced at plugin load time with hostIP and open tracing kong plugin will send the traces to the OT Collector that's running on the same host.
It just needs to be designed similar to Datadog plugin config, that config should also be read from environmental variable.
Steps To Reproduce
Try setting up plugin in Kubernetes, and see if you can send traces to the agent/collector running on the host/node. Please note that we don't want to run the collector as service, which means the traces go across the nodes.
Anything else?
Any workarounds? What do you think about following work around? We set the config endpoint as endpoint: http://host_ip:4318/v1/traces. and run echo 'host_ip $HOST_IP' >> /etc/hosts after pod startup. This would mean open tracing won't be able to connect for few seconds, and then it will connect. But, we're modifying the immutable image, and It's a hacky workaround :(