3

I'm trying to use a Kong plugin for k8s ingress customization. Specifically, i'm using the Kong ingress controller and the "request-transformer-advanced" plugin (Reference: https://docs.konghq.com/hub/stone-payments/kong-plugin-url-rewrite/)

The Kong plugin page (reference above) discusses installing and configuring the plugin using URL calls with payloads. However, most k8s configuration i'm familiar with is via YAMLs (e.g., https://kubernetes.io/docs/concepts/services-networking/ingress/)

Are the Kong plugins also configurable via YAML? Some third party sites mention configurations such as this:

apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  name: deploymentname187
config:
  config.replace.uri: /
plugin: kong-plugin-url-rewrite

What is the best practice for Kong plugins -- URL calls or YAML application?

Nick
  • 1,882
  • 11
  • 16
CoderOfTheNight
  • 944
  • 2
  • 8
  • 21

2 Answers2

1

It depends. If you are storing your kong configuration and other kong entities in Kubernetes via repository then it makes sense to use YAML files.

On the other hand, if you install Kong by manually invoking kubectl apply -f, then you can proceed with URL.

vvavepacket
  • 1,882
  • 4
  • 25
  • 38
1

The Kong plugin page discusses installing and configuring the plugin using URL calls with payloads. However, most k8s configuration i'm familiar with is via YAMLs

I have been checking the Kong's installation guide and it specifies that:

Setting up Kong for Kubernetes is as simple as: $ kubectl apply -f http://.../all-in-one-dbless.yaml

So technically, here we are just fetching plain YAML file from their repo.

As a result, a few Custom Resource Definitions are installed (with all the needed stuff like namespace, etc). Particularly the following CRD is described there:

apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: kongplugins.configuration.konghq.com
spec:
...
  names:
    kind: KongPlugin

Are the Kong plugins also configurable via YAML?

After installing the plugin you can manage the configuration in a declarative way. Exactly as it is specified on a Kong plugin page you've been reffering to:

Enabling the plugin on a Service Declarative (YAML) For example, configure this plugin on a Service by adding this section to your declarative configuration file:

plugins:
- name: kong-plugin-url-rewrite
service: <service>
config: 
  url: http://new-url.com

<service> is the id or name of the Service that this plugin configuration will target.

Your next quistion is a very opinion based one.

What is the best practice for Kong plugins -- URL calls or YAML application?

as WantIt told, you can either install via kubectl -f URL or kubectl -f local_YAML the result will be the same (if the URL contains the same YAML).

Nick
  • 1,882
  • 11
  • 16