Deploy Multiple Kong Instances on different namespaces in a k8s cluster

Is it possible to deploy one instance of kong per namespace on a k8s cluster?

I don’t want all request to all my services to be routed through just one loadbalancer (the loadbalancer created by kong).

Does any one have a way around this?

cc: @thibaultcha @hisham

Yes, this should be possible.

Have you tried doing it and are facing any specific problem?

After installing Kong according to the steps specified in the documentation, I tried to deploy two different ingresses in separate namespaces, both having an annotation of kubernetes.io/ingress.class: "kong". I however noticed the the two ingresses have the same address when I run kubectl get ingress in the different namespaces.

Is it possible to get different addresses (i.e different loadbalancers ) for different kong ingresses?

You will need to deploy two Ingress Controllers with different ingress.class.

Basically, ingress.class is used to filter the ingresses that an Ingress controller should satisfy.

Once, you deploy two ingress controllers with different ingress.class, create one ingress rule with ingress.class of the first controller and another with the ingress.class of the second controller, and you should see both get different addresses.

3 Likes

I was running into to same issue. Thank you for help! :blush:

Thx for the answer, I’m not 100% clear on the solution.

This is what I think I have to do (for each namespace):

apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
  name: kong-my-namespace
spec:
  controller: ingress-controllers.konghq.com/kong
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ams-web                        
  namespace: my-namespace
  annotations:
    konghq.com/protocols: http          # Upstream protocol
spec:
  ingressClassName: kong-my-namespace
  rules:
...