How can I set the "Enabled" property to false on a plugin in Kubernetes?

I’m trying to add a plugin to Kong in Kubernetes.

I want my plugin configuration to always be part of my yaml file. But the file will be tokenized so that I can set a variable at deployment time to decide whether the plugin will be enabled .

It would look like this.
Except in this case the Enabled label makes no difference. Is there any way to achieve this?

apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  name: global-prometheus
  labels:
    global: "true"
    enabled: ${Some_tokenized_value_replaced_at_deployment_time}
  namespace: kong
  annotations:
    kubernetes.io/ingress.class: XXXXXX
plugin: prometheus

I have tried this, but setting disabled to true didn’t seem to disable my plugin:

apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  name: global-prometheus
  labels:
    global: "true"
  namespace: kong
  annotations:
    kubernetes.io/ingress.class: XXXXXX
plugin: prometheus
disabled: ${Some_tokenized_value_replaced_at_deployment_time}

Can you share the complete KongPlugin after it was rendered (what you get from kubectl get kongplugin global-prometheus) for us to try and replicate? Setting disabled in the KongPlugin manifest should control the disabled setting on the plugin within Kong.

NAME                PLUGIN-TYPE   AGE
global-prometheus   prometheus    3h59m

Describe command returns this:

Name:         global-prometheus
Namespace:    kong
Labels:       global=true
Annotations:  kubectl.kubernetes.io/last-applied-configuration:
                {"apiVersion":"configuration.konghq.com/v1","disabled":true,"kind":"KongPlugin","metadata":{"annotations":{"kubernetes.io/ingress.class":"...
              kubernetes.io/ingress.class: XXXXXX
API Version:  configuration.konghq.com/v1
Disabled:     true
Kind:         KongPlugin
Metadata:
  Creation Timestamp:  2020-05-14T14:23:08Z
  Generation:          9
  Resource Version:    37235502
  Self Link:           /apis/configuration.konghq.com/v1/namespaces/kong/kongplugins/global-prometheus
  UID:                 1ad6cf5b-012f-409e-9a94-a254cc962f1c
Plugin:                prometheus
Events:                

The log of the kong ingress-controller shows:
I0514 18:32:52.251742 1 kong.go:71] successfully synced configuration to Kong

After that, I navigate to the Kong metrics URL generated by the plugin and it shows the list of available metrics.
I would expect it to not return nothing.

Sorry, should have been kubectl get kongplugin global-prometheus -o yaml. That said, I think this is normal–disabling the plugin ignores it during request processing, but doesn’t disable any admin API endpoints it provides–those exist even if there are no instances of the plugin configured at all. You’ll still see the metrics endpoint, but it won’t start providing actual request data until the plugin is enabled.

Thanks for the reply.
I have tried disabling the plugin with “disabled: true”.
I can confirm it was taken into account when check with kublectl.

However, I’m still receiving new metrics on Prometheus.

Actually after more testing I see that when disabled=true, I’m still receiving metrics bit they are at 0.
Whereas when disabled=false, I’m receiving the actual metrics.

It`s very confusing to still be receiving metrics when the plugin is supposed to be disabled.


© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ