Kong Ingress Controller - Datadog Plugin

#1

Hi,

I’m using the kong ingress controller and I’m trying to configure the Datadog plugin. Datadog is deployed to Kubernetes as well via a DaemonSet. The way other services talk to the Datadog agent is via an environment variable set via the Kubernetes downward API. I added the following to my kong deployment:

env:
  - name: DD_AGENT_SERVICE_HOST
    valueFrom:
    fieldRef:
      apiVersion: v1
      fieldPath: status.hostIP

This environment works and I’m able to access $DD_AGENT_SERVICE_HOST from each kong pod.

I’m now trying to configure the Datadog plugin with the following:

apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  labels:
    global: "true"
  name: datadog
plugin: datadog
config:
  host: $DD_AGENT_SERVICE_HOST

After applying the above, the kong-ingress-controller pod logs the following:
ingress-controller creating a global Kong plugin [ nil datadog nil nil nil nil map[host:$DD_AGENT_SERVICE_HOST] ]: 400 Bad Request {"message":"schema violation (config.host: invalid value: $DD_AGENT_SERVICE_HOST)","name":"schema violation","fields":{"config":{"host":"invalid value: $DD_AGENT_SERVICE_HOST"}},"code":2}

Is it possible to configure Kong plugins with environment variables? If not, any recommendations or workarounds? I tried setting the host value to a specific node’s IP in my cluster and the plugin worked, but that won’t work long-term because node IPs are ephemeral.

Thanks!

0 Likes

#2

Indeed, this is a sane and valid deployment model but I’m afraid I’m not aware of any way to do solve with plugin configs.

I’m not very familiar with k8s’s hostNetwork interface, may be you could setup up DNS in such a way that it resolves within the hostNetwork and hence to your daemon set?

0 Likes