-
-
Notifications
You must be signed in to change notification settings - Fork 453
Feature: Disable public ips on autoscaled nodes #1695
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
Feature: Disable public ips on autoscaled nodes #1695
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @xavierleune, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
This pull request introduces the ability to disable public IPv4 and IPv6 addresses on autoscaled nodes within the Kubernetes cluster managed by this Terraform module. This feature enhances security and reduces costs by preventing the assignment of public IPs to nodes that only require internal network access. The changes involve adding new variables to control the disabling of public IPs, modifying the autoscaler agent configuration to reflect these settings, and updating the documentation to reflect the new feature.
Highlights
- New Feature: Introduces
autoscaler_disable_ipv4
andautoscaler_disable_ipv6
variables to disable public IPs on autoscaled nodes. - Configuration Changes: Modifies
autoscaler-agents.tf
to pass the disable IPv4/IPv6 flags to the cloud-init configuration. - Cloud-init Template Update: Updates
templates/autoscaler-cloudinit.yaml.tpl
to configure the default route based on public IP availability. - Documentation Update: Updates
README.md
andkube.tf.example
to document the newautoscaler_disable_ipv4
andautoscaler_disable_ipv6
variables.
Changelog
Click here to see the changelog
- README.md
- Added documentation for
autoscaler_disable_ipv4
andautoscaler_disable_ipv6
variables, explaining how to disable public IPs on autoscaled nodes. - Updated line 1016 to include the new variables.
- Added documentation for
- autoscaler-agents.tf
- Passed
var.autoscaler_disable_ipv4
andvar.autoscaler_disable_ipv6
to thelocal
context for use in cloud-init configuration (line 44). - Added
private_network_only
parameter todata "cloudinit_config" "autoscaler_config"
anddata "cloudinit_config" "autoscaler_legacy_config"
based on the IPv4/IPv6 disable flags (lines 122 and 157).
- Passed
- kube.tf.example
- Added example configuration for disabling public IPs on autoscaled nodes using
autoscaler_disable_ipv4
andautoscaler_disable_ipv6
(lines 364-366).
- Added example configuration for disabling public IPs on autoscaled nodes using
- templates/autoscaler-cloudinit.yaml.tpl
- Added conditional logic to configure the default route based on the
private_network_only
flag (lines 46-50).
- Added conditional logic to configure the default route based on the
- templates/autoscaler.yaml.tpl
- Added conditional logic to set
HCLOUD_PUBLIC_IPV4
andHCLOUD_PUBLIC_IPV6
environment variables to "false" if the corresponding disable flags are set (lines 197-204).
- Added conditional logic to set
- variables.tf
- Added
autoscaler_disable_ipv4
variable with a description and default value offalse
(lines 362-366). - Added
autoscaler_disable_ipv6
variable with a description and default value offalse
(lines 368-372).
- Added
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
No public IPs,
A private network's grace,
Security thrives now.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces the ability to disable public IPs on autoscaled nodes, which enhances security and reduces costs for users who don't require public IPs. The changes seem well-structured and cover the necessary files. However, there are a few points that need attention to ensure correctness and maintainability.
Summary of Findings
- Conditional Default Route Configuration: The logic for configuring the default route based on public IP availability in
autoscaler-cloudinit.yaml.tpl
relies on theprivate_network_only
variable. It's crucial to ensure that this logic is robust and handles all possible scenarios correctly to avoid routing issues. - Variable Description Consistency: The descriptions for
autoscaler_disable_ipv4
andautoscaler_disable_ipv6
variables invariables.tf
are identical. While functionally correct, consider rephrasing them slightly to emphasize the specific IPv version being disabled for clarity. - HCloud Public IP Environment Variables: The
templates/autoscaler.yaml.tpl
file sets environment variablesHCLOUD_PUBLIC_IPV4
andHCLOUD_PUBLIC_IPV6
to "false" based on thedisable_ipv4
anddisable_ipv6
variables. Ensure that these environment variables are correctly utilized by the cluster autoscaler to prevent the allocation of public IPs.
Merge Readiness
The pull request introduces a valuable feature for disabling public IPs on autoscaled nodes. However, before merging, it's essential to address the identified issues, particularly the conditional default route configuration and variable description consistency. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging. Given the medium
severity issues identified, I recommend that these be addressed before merging.
node_pools = var.autoscaler_nodepools, | ||
disable_ipv4 = var.autoscaler_disable_ipv4, | ||
disable_ipv6 = var.autoscaler_disable_ipv6, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a comment explaining why these variables are being passed directly into the local
block. This will help future maintainers understand the purpose of these variables and how they affect the autoscaler configuration.
node_pools = var.autoscaler_nodepools,
# Pass disable_ipv4 and disable_ipv6 to configure network settings for autoscaled nodes
disable_ipv4 = var.autoscaler_disable_ipv4,
disable_ipv6 = var.autoscaler_disable_ipv6,
# Configure default route based on public ip availability | ||
%{if private_network_only~} | ||
- [ip, route, add, default, via, '10.0.0.1', dev, 'eth0'] | ||
%{else~} | ||
- [ip, route, add, default, via, '172.31.1.1', dev, 'eth0'] | ||
%{endif~} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section configures the default route based on private_network_only
. It's crucial to ensure that this logic is robust and handles all possible scenarios correctly. Consider adding comments to explain the IP addresses used (10.0.0.1 and 172.31.1.1) and their significance in the context of Hetzner Cloud networking. What happens if neither of these routes are valid?
# Configure default route based on public ip availability
%{if private_network_only~}
# 10.0.0.1 is the gateway for private networks
- [ip, route, add, default, via, '10.0.0.1', dev, 'eth0']
%{else~}
# 172.31.1.1 is the gateway for public networks
- [ip, route, add, default, via, '172.31.1.1', dev, 'eth0']
%{endif~}
Great 👌 |
Any chance we can see this merged soon? Also, just for my understanding, why do we make |
@loomsen the pull request hetznercloud/terraform-provider-hcloud#1115 has been merged but now we should wait for the release of the version 1.51.0 hetznercloud/terraform-provider-hcloud#1119, feel free to reach on this pull request ^^ |
Well done @xavierleune, as soon as hcloud 1.51.0 is shipped, going to merge this. Please if you can, add the minimum hcloud version in the code, you can grep for "hetznercloud/hcloud" to find the locations where to update the values. |
Well, that was quick, 1.51.0 got released :) |
(Maintainer of the terraform provider) We try to cut releases regularly without overwhelming users with too many small releases. If you reach out and say that you are actually blocked by it then this tips the scales, and we usually cut the release quickly. |
@mysticaltech can we go ahead and merge here? :) I could drop my local patch version then |
@mysticaltech requirements are up to date ! |
Thank you everyone, on it. |
The pull request #1567 lacks implementation for autoscaled nodes.