Environment variables in Plugin Configuration

I am using Kong Ingress Controller 0.8.1 and trying to configure few plugins including custom ones. I am able to get them working however I would like to configure some of the plugin parameters using environment variables. E.g. provide a plugin parameter with value of the Kubernetes Node IP on which Kong Pod is running. Is this possible and if so how would I do it via declarative configuration?

---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: ingress-kong
  name: ingress-kong
  namespace: kong
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ingress-kong
  template:
    metadata:
      annotations:
        kuma.io/gateway: enabled
        prometheus.io/port: "9542"
        prometheus.io/scrape: "true"
        traffic.sidecar.istio.io/includeInboundPorts: ""
      labels:
        app: ingress-kong
    spec:
      containers:
      - env:
        - name: POD_HOST_IP
          valueFrom:
            fieldRef:
              fieldPath: status.hostIP
...
---
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  name: my-plugin
  namespace: myns
config:
  kongNodeIP: <POD_HOST_IP> # how to specify POD env variable here?
plugin: my-plugin
---

To clarify, are you looking to specify the environment variable name or the environment variable value? The latter isn’t possible because the KongPlugin exists outside the Pod and isn’t sent to it directly, it’s translated into its Kong-native format and then applied through the admin API.

Specifying the name should work, but with caveats:

Thanks for the response. I was hoping for using the environment variable value which looks like is not possible. I will try alternative options for my configuration.


© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ