Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: populate ingress private ip when disable-private-ingress is false #715

Merged
merged 1 commit into from
Aug 16, 2024

Conversation

jooola
Copy link
Member

@jooola jooola commented Aug 13, 2024

Closes #553

Refactor getting the ingresses for a load-balancer for both get load-balancer and ensure load-balancer, into using a shared function. This ensures we are consistent between the 2 methods.

Release notes:
The load balancer ingress IPs are now populated with the private IPs, unless the load-balancer.hetzner.cloud/disable-private-ingress annotation is set to true. Please make sure that you configured the annotation according to your needs, for example if you are using external-dns.

@jooola jooola requested a review from a team as a code owner August 13, 2024 12:34
@jooola jooola requested a review from apricote August 13, 2024 12:34
@jooola jooola changed the title fix: populate ingress ip when disable-public-network is set fix: populate ingress private ip when disable-public-network is set Aug 13, 2024
Copy link

codecov bot commented Aug 13, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 2 lines in your changes missing coverage. Please review.

Project coverage is 72.11%. Comparing base (e0b43d4) to head (2424b41).
Report is 2 commits behind head on main.

Files Patch % Lines
hcloud/load_balancers.go 83.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #715      +/-   ##
==========================================
- Coverage   72.18%   72.11%   -0.08%     
==========================================
  Files          31       31              
  Lines        2639     2639              
==========================================
- Hits         1905     1903       -2     
- Misses        549      550       +1     
- Partials      185      186       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jooola
Copy link
Member Author

jooola commented Aug 13, 2024

image

Copy link
Member

@apricote apricote left a comment

Choose a reason for hiding this comment

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

Awesome!

@apricote
Copy link
Member

apricote commented Aug 14, 2024

Ah, this now always adds the private ip to the addresses if set. IIRC we discussed that we want to add it only when no public IPs are available.

See this comment for an explanation why this change could be dangerous.

Copy link
Member

@apricote apricote left a comment

Choose a reason for hiding this comment

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

See above comment

@jooola
Copy link
Member Author

jooola commented Aug 14, 2024

In that case, I am not sure to fully understand why it should be different between EnsureLoadBalancer and GetLoadBalancer. According to the cloud provider interface, I understand that both should not be really different, apart from the latter being read-only.

If we need this difference to prevent a breaking change, we might not respect the load-balancer.hetzner.cloud/disable-public-network and load-balancer.hetzner.cloud/disable-private-ingress annotations.

I think I understood that external dns might break because we are referencing a private IP that will never be reachable from the outside, but in that case people would have to set disable-private-ingress=true.

I might be missing something though :)

EDIT: maybe I am just questioning whether we should do a breaking change for this fix.

@jooola jooola changed the title fix: populate ingress private ip when disable-public-network is set fix: populate ingress private ip when disable-private-ingress is false Aug 15, 2024
@apricote
Copy link
Member

We investigated the history of this today. Looking at #49 and #118 it was intended that we always add external+internal IPs the the Service Status. The annotation load-balancer.hetzner.cloud/disable-private-ingress=true was meant to help with setups where this causes issues.

So this PR fixes a bug and restores the intended behavior.

Closes #553

Refactor getting the ingresses for a load-balacencer for both get load-balancer and ensure load-balancer, into using a shared function. This ensure we are consistent between the 2 methods.
@jooola jooola merged commit 8d29153 into main Aug 16, 2024
9 checks passed
@jooola jooola deleted the fix-553 branch August 16, 2024 08:12
lukasmetzner pushed a commit that referenced this pull request Nov 26, 2024
<!-- section-start changelog -->
### Feature Highlights &amp; Upgrade Notes

#### Load Balancer IPs set to Private IPs

If networking support is enabled, the load balancer IPs are now
populated with the private IPs, unless the
`load-balancer.hetzner.cloud/disable-private-ingress` annotation is set
to `true`. Please make sure that you configured the annotation according
to your needs, for example if you are using `external-dns`.

#### Provided-By Label

We introduced a the label `instance.hetzner.cloud/provided-by`, which
will be automatically added to all **new** nodes. This label can have
the values `cloud` or `robot` to distinguish between our products. We
use this label in the csi-driver to ensure the daemonset is only running
on cloud nodes. We recommend to add this label to your existing nodes
with the appropriate value.

- `kubectl label node $CLOUD_NODE_NAME
instance.hetzner.cloud/provided-by=cloud`
- `kubectl label node $ROBOT_NODE_NAME
instance.hetzner.cloud/provided-by=robot`

#### Load Balancer IPMode Proxy

Kubernetes KEP-1860 added a new field to the Load Balancer Service
Status that allows us to mark if the IP address we add should be
considered as a Proxy (always send traffic here) and VIP (allow
optimization by keeping the traffic in the cluster).

Previously Kubernetes considered all IPs as VIP, which caused issues
when when the PROXY protocol was in use. We have previously recommended
to use the annotation `load-balancer.hetzner.cloud/hostname` to
workaround this problem.

We now set the new field to `Proxy` if the PROXY protocol is active so
the issue should no longer appear. If you only added the
`load-balancer.hetzner.cloud/hostname` annotation for this problem, you
can remove it after upgrading.

Further information:

- kubernetes/enhancements#1860
-
#160 (comment)

### Features

- **service**: Specify private ip for loadbalancer (#724)
- add support &amp; tests for Kubernetes 1.31 (#747)
- **helm**: allow setting extra pod volumes via chart values  (#744)
- **instance**: add label to distinguish servers from Cloud and Robot
(#764)
- emit event when robot server name and node name mismatch (#773)
- **load-balancer**: Set IPMode to &#34;Proxy&#34; if load balancer is
configured to use proxy protocol (#727) (#783)
- **routes**: emit warning if cluster cidr is misconfigured (#793)
- **load-balancer**: ignore nodes that don&#39;t use known provider IDs
(#780)
- drop tests for kubernetes v1.27 and v1.28

### Bug Fixes

- populate ingress private ip when disable-private-ingress is false
(#715)
- wrong version logged on startup (#729)
- invalid characters in label instance-type of robot servers (#770)
- no events are emitted as broadcaster has no sink configured (#774)

### Kubernetes Support

This version was tested with Kubernetes 1.29 - 1.31. Furthermore, we
dropped v1.27 and v1.28 support.

<!-- section-end changelog -->

---

<details>
<summary><h4>PR by <a
href="https://github.com/apricote/releaser-pleaser">releaser-pleaser</a>
🤖</h4></summary>

If you want to modify the proposed release, add you overrides here. You
can learn more about the options in the docs.

## Release Notes

### Prefix / Start

This will be added to the start of the release notes.

```rp-prefix
### Feature Highlights & Upgrade Notes

#### Load Balancer IPs set to Private IPs

If networking support is enabled, the load balancer IPs are now populated with the private IPs, unless the `load-balancer.hetzner.cloud/disable-private-ingress` annotation is set to `true`. Please make sure that you configured the annotation according to your needs, for example if you are using `external-dns`.

#### Provided-By Label

We introduced a the label `instance.hetzner.cloud/provided-by`, which will be automatically added to all **new** nodes. This label can have the values `cloud` or `robot` to distinguish between our products. We use this label in the csi-driver to ensure the daemonset is only running on cloud nodes. We recommend to add this label to your existing nodes with the appropriate value.

- `kubectl label node $CLOUD_NODE_NAME instance.hetzner.cloud/provided-by=cloud`
- `kubectl label node $ROBOT_NODE_NAME instance.hetzner.cloud/provided-by=robot`

#### Load Balancer IPMode Proxy

Kubernetes KEP-1860 added a new field to the Load Balancer Service Status that allows us to mark if the IP address we add should be considered as a Proxy (always send traffic here) and VIP (allow optimization by keeping the traffic in the cluster).

Previously Kubernetes considered all IPs as VIP, which caused issues when when the PROXY protocol was in use. We have previously recommended to use the annotation `load-balancer.hetzner.cloud/hostname` to workaround this problem.

We now set the new field to `Proxy` if the PROXY protocol is active so the issue should no longer appear. If you  only added the `load-balancer.hetzner.cloud/hostname` annotation for this problem, you can remove it after upgrading.

Further information:
- kubernetes/enhancements#1860
- #160 (comment)
```

### Suffix / End

This will be added to the end of the release notes.

```rp-suffix
### Kubernetes Support

This version was tested with Kubernetes 1.29 - 1.31. Furthermore, we dropped v1.27 and v1.28 support.
```

</details>

Co-authored-by: releaser-pleaser <>
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.

LoadBalancer does not populate IP field when disable-public-network is set.
2 participants