Change Load Balancing Algorithm used by Gateway

Hello, the docs for Kong Ingress Controller mention:

The Kubernetes Ingress Controller does not use Services to route traffic to the pods. Instead, it uses the Endpoints API to bypass kube-proxy to allow Kong features like session affinity and custom load balancing algorithms.

In the documentation for Kong Gateway, I found that several load balancing algorithms are supported. Though it seems that an Upstream is required to configure the used algorithm (which I am not sure is available in a K8s environment).

Now, I’m not sure if it isn’t documented, or I just can’t find it. But I’m wondering if/how a custom load balancing algorithm can be configured for the Kong Ingress Controller?

The controller creates upstreams automatically for all Services. You can tune its parameters by attaching a KongIngress resource with an override annotation. For example:

apiVersion: configuration.konghq.com/v1
kind: KongIngress
metadata:
  name: configuration-demo
upstream:
  algorithm: least-connections
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: echo
  annotations:
    konghq.com/override: configuration-demo
  name: echo
spec:
  ports:
  - port: 8080
    name: high
    protocol: TCP
    targetPort: 8080