How to load balancing to pods of service?

Hi, I’m using Kong kubernetes ingress as API gateway. It proxies to an k8s internal service called “device-execer”.

How should I load balance the requests to specific pod of the service?

Two possible scenarios:

  1. By user IP. For all requests from a IP, proxies to a fixed pod.
  2. By url. For all requests to /dev/11:22:33:44:55, to pod1, while those to /dev/aa:bb:cc:dd:ee:ff, to pod2.

Are there solutions for the either of two scenarios?

I’m new to Kong. Thanks a lot!

Please look into the upstream entity of Kong, and read up on KongIngress Custom Resource, which allows you to specify the load-balancing strategies.

You can do hash based load balancing to route request based on client IP.

@Tieske can give more details on which properties to use.

See the upstream entity here: https://docs.konghq.com/2.0.x/admin-api/#create-upstream

The approach uses “consistent-hashing”, there are a number of properties that can be used as the input for the hash. The upstream-property you’re looking for is the hash_on field (and hash_fallback).

Also read the LB reference: https://docs.konghq.com/2.0.x/loadbalancing/

Thanks a lot! @Tieske and @hbagdi


© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ