Skip to content

Conversation

@href
Copy link
Contributor

@href href commented Aug 22, 2024

See #15

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.
@href href force-pushed the denis/lb-status-hostname branch from 8a89b09 to 1a1feae Compare August 22, 2024 15:51
@href href requested a review from alakae August 22, 2024 15:55
@href href self-assigned this Aug 22, 2024
@href href force-pushed the denis/lb-status-hostname branch from 1a1feae to fa7d151 Compare August 23, 2024 07:21
@href href changed the title Add option to prevent cluster-traffic from sidestepping loadbalancers Add option to prevent cluster-traffic from bypassing loadbalancers Aug 23, 2024
@href href force-pushed the denis/lb-status-hostname branch 5 times, most recently from ce903d9 to e3b8612 Compare August 23, 2024 08:40
Copy link
Contributor

@alakae alakae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@href href force-pushed the denis/lb-status-hostname branch from e3b8612 to 0c0afd8 Compare August 27, 2024 06:51
@href href merged commit b9a06a9 into main Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants