SNI routing using the nginx map preread module #1432
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I want to preface this by saying that this is a disgusting pile of a diff here. The purpose of me sharing this commit is to share how I'm using the project and possibly spawn conversation.
I was a little surprised to learn that the current SNI routing system implemented by this project is not actually leveraging nginx at all, but is entirely done in golang. I simply was unwilling to connect the current ingress sni routing feature to the Internet. nginx, however, is tried and true and supports SNI routing.
I modeled this change after the TCP l4 stuff that already exists, there's a fair bit of copy-pasta in here.
I also really wanted to leverage the serviceUpstream change that is reasonably recent to the project. My deployment of Kubernetes relies on having persistent connections last as long as possible because TLS handshakes are expensive. During deployments every time the "pod topology" changed (i.e. anytime a pod changed status) nginx would reload it's configuration and recycle, ultimately nuking all open connections. Using serviceUpstream we are ~never reloading our nginx config and therefore aren't artificially terminating connections.
Again, I don't expect this code to ever get merged, at least not as-is. I just wanted the maintainers to be able to see how we're using the project.
Since you might be wondering why I would deploy code that I don't want merged upstream: we're expecting to migrate away from SNI routing ~soon. This is a stopgap (prior to this we were SNI routing with haproxy and code that looks like an ingress controller but that predates ingress controllers).