Kong Custom Plugin in Kubernetes

Hello Folks ,

We have created custom plugin and we have deployed same in kubernetes , Plugin global plugin and we have generated config using deck utility .

This is my Kong.yaml file

_format_version: "1.1"
services:
- connect_timeout: 5000
  host: dummyurl
  name: aggregation
  port: 80
  protocol: http
  read_timeout: 5000
  retries: 1
  write_timeout: 5000
  routes:
  - name: dumy_url
    methods:
    - GET
    paths:
    - /dummy/v1
    path_handling: v1
    preserve_host: true
    protocols:
    - http
    - https
    regex_priority: 0
    strip_path: false
    https_redirect_status_code: 426
    plugins:
plugins:
- name: app-config
  config:
    config: |-
      {
        "default": {
          "services": {
            "xyz": "xyz.abc.com"
        }
      }
  enabled: true
  protocols:
  - grpc
  - grpcs
  - http
  - https

I wanted to translate the same global plugin resource into Kubernetes native CRD implementation

apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  name: app-config
  labels:
    global: "true"
config:
  config: |-
      {
        "default": {
          "services": {
            "xyz": "xyz.abc.com"
            }
          }
      }
plugin: app-config

But somehow this is not working . Can you guys please suggest what’s the mistake I am performing .

In continuation with same how to embed json config in KongPlugin/KongClusterPlugin resource .

Update there was issue in indention of KongClusterPlugin resource

 --- 
apiVersion: configuration.konghq.com/v1
config: 
  config: |-
      {
        "default": {
          "services": {
            "xyz": "xyz.abc.com"
            }
          }
      }
kind: KongClusterPlugin
metadata: 
  labels: 
    global: "true"
  name: app-config
plugin: app-config

Still I am not able to view in konga dashboard plugins section as global plugin

Update : This is fixed by adding

metadata:
  annotations:
    kubernetes.io/ingress.class: kong

© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ