Add option to prevent cluster-traffic from bypassing loadbalancers#16
Merged
Add option to prevent cluster-traffic from bypassing loadbalancers#16
Conversation
The server can be run as follows: cd cmd/http-echo go run main.go Then in a separate shell: curl http://127.0.0.1/proxy-protocol/used --haproxy-protocol false curl http://127.0.0.1/proxy-protocol/used --haproxy-protocol true This tool could live outside this repository and may one day just do that, once it has more fetures and could replace the nginx hello server used in other places.
8a89b09 to
1a1feae
Compare
1a1feae to
fa7d151
Compare
ce903d9 to
e3b8612
Compare
alakae
approved these changes
Aug 26, 2024
Contributor
alakae
left a comment
There was a problem hiding this comment.
Thank you! Just a single suggestion.
Comment on lines
+137
to
+180
| // LoadBalancerForceHostname forces the CCM to report a specific hostname | ||
| // to Kubernetes when returning the loadbalancer status, instead of | ||
| // reporting the IP address(es). | ||
| // | ||
| // The hostname used should point to the same IP address that would | ||
| // otherwise be reported. This is used as a workaround for clusters that | ||
| // do not support status.loadBalancer.ingress.ipMode, and use `proxy` or | ||
| // `proxyv2` protocol. | ||
| // | ||
| // For newer clusters, .status.loadBalancer.ingress.ipMode is automatically | ||
| // set to "Proxy", unless LoadBalancerIPMode is set to "VIP" | ||
| // | ||
| // For more information about this workaround see | ||
| // https://kubernetes.io/blog/2023/12/18/kubernetes-1-29-feature-loadbalancer-ip-mode-alpha/ | ||
| LoadBalancerForceHostname = "k8s.cloudscale.ch/loadbalancer-force-hostname" |
Contributor
There was a problem hiding this comment.
As discussed, I'd suggest to mention .status.loadBalancer.ingress.hostname here and make explicit, that it essentially sets that property.
Other than that: LGTM
This is accomplished with two new annotations: - `k8s.cloudscale.ch/loadbalancer-force-hostname` - `k8s.cloudscale.ch/loadbalancer-ip-mode` The former forces a hostname to be reported for loadbalancer ingress, the latter adds support for the new IPMode config available by default on Kubernetes 1.30, and feature-gated on 1.29. This is required for clusters that use the `proxy` or `proxyv2` protocol for any of their loadbalancers, and send traffic from inside the cluster to the loadbalancers. In such a constellation, traffic may not be sent through the loadbalancer, unless the hostname is set (for older clusters). For newer cluster, the default "IP Mode" used is "Proxy", as that is the least surprising setting. References: - https://kubernetes.io/blog/2023/12/18/kubernetes-1-29-feature-loadbalancer-ip-mode-alpha/ - #15
e3b8612 to
0c0afd8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
See #15