javier-ruiz-voxsmart commented on issue #12747:
URL: https://github.com/apache/apisix/issues/12747#issuecomment-5003171948

   ## Resolution — Full Root Cause and Fix (Kubernetes + Helm + Ingress 
Controller)
   
   After extensive debugging, I'm sharing the full resolution for anyone 
hitting this in a Kubernetes environment with the APISIX Helm chart and 
ingress-controller.
   
   ### Root Cause
   
   The Datadog plugin reads `host` and `port` from **`plugin_metadata`** 
(stored in etcd), **not** from `plugin_attr` in `config.yaml`. This is the key 
distinction @Baoyuantop pointed out.
   
   However, in a Kubernetes + Helm + ingress-controller setup, there are 
additional gotchas:
   
   1. **`pluginAttrs.datadog` in Helm `values.yaml` is useless** — it renders 
to `plugin_attr` in `config.yaml`, which the Lua plugin ignores at runtime. The 
plugin defaults to `127.0.0.1:8125`.
   
   2. **Setting `plugin_metadata` via the Admin API (`PUT 
/apisix/admin/plugin_metadata/datadog`) gets wiped** — the ingress-controller 
reconciliation loop overwrites it.
   
   3. **Setting `host`/`port` in `ApisixGlobalRule` config does nothing** — 
`host` and `port` are metadata-level settings, not route/global config-level.
   
   ### The Fix — `GatewayProxy.spec.pluginMetadata`
   
   The correct declarative approach in Kubernetes is using the `GatewayProxy` 
CRD (`v1alpha1`), which has a `pluginMetadata` field that the 
ingress-controller syncs to etcd automatically:
   
   ```yaml
   # In Helm values.yaml under ingress-controller:
   ingress-controller:
     gatewayProxy:
       createDefault: true
       pluginMetadata:
         datadog:
           host: "datadog.monitoring.svc.cluster.local"  # Your DogStatsD 
service
           port: 8125
           namespace: "apisix"
           constant_tags:
             - "source:apisix"
             - "service:apisix"
             - "team:myteam"
   ```
   
   Additionally, enable the plugin globally via `ApisixGlobalRule`:
   
   ```yaml
   apiVersion: apisix.apache.org/v2
   kind: ApisixGlobalRule
   metadata:
     name: global-default
   spec:
     ingressClassName: apisix
     plugins:
       - name: datadog
         enable: true
         config:
           prefer_name: true
   ```
   
   ### Summary
   
   | What | Works? | Why |
   |------|--------|-----|
   | `pluginAttrs.datadog` in Helm values | No | Renders to `plugin_attr` in 
config.yaml — ignored by Lua plugin |
   | Admin API `PUT /plugin_metadata/datadog` | Temporarily | 
Ingress-controller reconciliation overwrites it |
   | `ApisixGlobalRule` config `host`/`port` | No | `host`/`port` are metadata, 
not config |
   | **`GatewayProxy.spec.pluginMetadata`** | **Yes** | Synced to etcd 
`plugin_metadata` by ingress-controller — survives reconciliation |
   
   ### Versions Tested
   
   - APISIX Helm chart: 2.16.0 (APISIX 3.17.0)
   - Ingress Controller: 1.2.0
   - Datadog Agent: 7.x (chart 3.230.0)
   
   Hope this helps anyone running into the same `connection refused` errors 
with the Datadog plugin in Kubernetes.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to