How to config service host via Kong Ingress?

I am using kong chart 1.5 with kong ingress controller 0.8.0 to deploy kong to our cluster via helm release.

I saw the service host has created automation when I set up via Ingress. Imagine it is review-web.staging.80.svc.

Now, I want to change it to another value. For example:

  • Change it to domain api.staging.example.com
  • Or point to another internal service another-service.staging.80.svc

By manual, I can do it, but I wonder how to do that via Kong Ingress?

You can set upstream.host_header in a KongIngress resource and then annotate your service using konghq.com/override. This will change the host-header to the value you prefer.

@hbagdi
Let me show you my configuration:

---
apiVersion: configuration.konghq.com/v1
kind: KongIngress
metadata:
  name: demo-ki
  namespace: default
upstream:
  host_header: "echo.internal.local"
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: demo
  namespace: default
  annotations:
    konghq.com/override: demo-ki
spec:
  rules:
  - http:
      paths:
      - path: /foo
        backend:
          serviceName: echo
          servicePort: 80 

After I applied that config, I expect the value of the service host is echo.internal.local. But it is not the same.

Two things:

  1. You need to put the konghq.com/override annotation on the Service resource for this to work.
  2. You will still not see the the host property of Service change. You will see the host_header property of the corresponding Upstream change.

Thank you for your prompt reply.
I have tested by following your guide and it worked with two things you noted.


© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ