Open NissesSenap opened 3 months ago
For anyone finding this issue, there is a workaround for this issue.
Which is that you have to define the hostname
in your gateway.
For example
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: kong
spec:
gatewayClassName: kong
listeners:
- name: https
protocol: HTTPS
port: 443
hostname: "*.example.com"
tls:
mode: Terminate
certificateRefs:
- name: example-com
kind: Secret
group: ""
allowedRoutes:
kinds:
- kind: HTTPRoute
namespaces:
from: All
- name: https-io
protocol: HTTPS
hostname: "*.example.io"
port: 443
tls:
mode: Terminate
certificateRefs:
- name: example-io
kind: Secret
group: ""
allowedRoutes:
kinds:
- kind: HTTPRoute
namespaces:
from: All
I read through the Gateway API documentation a few more times, and my understanding now is that unless you define a hostname in the Gateway, it is seen as the default TLS cert. So I can understand why Kong acts this way, when I had two listeners with no hostname defined.
Obviously, I think this is a bit error-prone, and it would be good to document this very clearly in Kong as well. The only way why I figured it out was from reading the gateway-api docs.
I might create an issue in Gateway API about this, since I personally think it shouldn't be possible to do the error I just did. I think it will be hard to write a good CEL rule to make sure this doesn't happen, but who knows. Another option could be to clarify this a bit within Gateway API, to make sure this is well-defined how the controllers should work.
I will leave the issue open, since I think it's a good thing to document.
Is there an existing issue for this?
Current Behavior
Unless I specify
hostname
when having multiple listeners defined inkind Gateway
, the routing of TLS don't seem to work, and instead I get the following error in the controller.Expected Behavior
Since I'm already defining sectionName in my httpRoute object, Kong shoulden't get any issues with the same SNI.
Example yaml
Steps To Reproduce
And a Gateway
Notice that
hostname: "*.example.com"
is missing from both the listeners This will give you the following error:This is even without having a httpRoute defined (which isn't strange from a code point of view). But if we look at the
httpRoute
object defined above we already useSo why would kong think that it's the same SNI requested for multiple certs?
Kubernetes version
Anything else?
I can imagine this being a pain to solve, and a workaround could be to just document how this works. I'm wondering how Gateway API think this should work. I haven't looked at this closer, but here you can find the docs: https://gateway-api.sigs.k8s.io/guides/tls/?h=tls#targetrefs-and-tls