feat: add allow_net_admin support to standard cluster modules#2550
feat: add allow_net_admin support to standard cluster modules#2550elayaraja-kv wants to merge 6 commits intoterraform-google-modules:mainfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello, 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! This pull request enhances Google Kubernetes Engine (GKE) cluster configurations by enabling the Highlights
Changelog
Activity
Using Gemini Code AssistThe 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 by creating a comment using either
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 Limitations & Feedback Gemini Code Assist 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request extends the allow_net_admin functionality, previously available only for Autopilot clusters, to all standard GKE cluster modules. The changes involve updating the Terraform templates to remove the conditional logic and then regenerating the module files. A manual update is also correctly applied to the gke-standard-cluster module. The changes are logical and maintain backward compatibility. My feedback focuses on improving the description of the new allow_net_admin variable to enhance security awareness for users, by making the potential risks of enabling this powerful capability more explicit. All comments have been kept as they do not contradict any provided rules.
Note: Security Review did not run due to the size of the PR.
autogen/main/variables.tf.tmpl
Outdated
| {% endif %} | ||
| {% if autopilot_cluster %} | ||
| variable "allow_net_admin" { | ||
| description = "(Optional) Enable NET_ADMIN for the cluster." |
There was a problem hiding this comment.
For better security awareness, it's good practice to be more explicit about the implications of enabling this option. The NET_ADMIN capability is powerful and should be used with caution. I suggest expanding the description to include a brief warning and a link to the relevant documentation.
description = "(Optional) Enable NET_ADMIN for containers in this cluster. This is a powerful capability. For more information, see https://cloud.google.com/kubernetes-engine/docs/how-to/hardening-your-cluster#restrict_pod_permissions"
| } | ||
|
|
||
| variable "allow_net_admin" { | ||
| description = "(Optional) Enable NET_ADMIN for the cluster." |
There was a problem hiding this comment.
For better security awareness, it's good practice to be more explicit about the implications of enabling this option. The NET_ADMIN capability is powerful and should be used with caution. I suggest expanding the description to include a brief warning and a link to the relevant documentation.
description = "(Optional) Enable NET_ADMIN for containers in this cluster. This is a powerful capability. For more information, see https://cloud.google.com/kubernetes-engine/docs/how-to/hardening-your-cluster#restrict_pod_permissions"
982757f to
07218bd
Compare
The allow_net_admin attribute was previously gated behind the autopilot_cluster condition in the autogen template, making it unavailable for standard (non-autopilot) cluster modules. Since the google_container_cluster resource supports allow_net_admin for all cluster types, expose it as a variable across all standard cluster modules for parity with the autopilot modules. Also update gke-standard-cluster to use a variable instead of the hardcoded false value, allowing users of that module to enable it.
07218bd to
693c0c8
Compare
e3627dd to
d0b12a9
Compare
|
Per the provider documentation, it appears this field should only be enabled for Autopilot clusters. https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#allow_net_admin-1 |
|
Thanks for the review, @apeabody! You are right that the provider docs say "should only be enabled for Autopilot clusters" -- that is the primary and most impactful use case, and I have updated the variable description across all affected files to make that clear. To clarify the distinction:
The intent of this PR is not to encourage use on standard clusters, but to remove an arbitrary autogen gate so that:
The updated description now reads:
Happy to make further adjustments if you prefer a different approach. |
Update variable description to explain that allow_net_admin is primarily intended for Autopilot clusters (where it is the only way to grant NET_ADMIN), and that standard cluster workloads can use NET_ADMIN via pod securityContext (e.g. for service meshes like Linkerd/Istio without CNI mode).
cf8292b to
12cd4e9
Compare
Regenerate module files and documentation to fix lint check failures.
Description
allow_net_adminenables the NET_ADMIN capability on the cluster master and is fully supported by thegoogle_container_clusterresource for all cluster types (see provider docs). However, the autogen template gated it behind{% if autopilot_cluster %}, making it unavailable for standard (non-autopilot) cluster modules.This PR brings parity with the autopilot modules by exposing
allow_net_adminacross all standard cluster modules.Changes
autogen/main/cluster.tf.tmpl— removed{% if autopilot_cluster %}gate soallow_net_adminis included for all cluster typesautogen/main/variables.tf.tmpl— same, moved variable declaration outside the autopilot condition, and aligned formatting (type/defaultspacing)allow_net_admin = var.allow_net_admintocluster.tfand the variable declaration tovariables.tf:modules/private-clustermodules/private-cluster-update-variantmodules/beta-private-clustermodules/beta-private-cluster-update-variantmodules/beta-public-clustermodules/beta-public-cluster-update-variantmodules/gke-standard-cluster— changed hardcodedallow_net_admin = falsetovar.allow_net_adminand added the variable (defaultfalseto preserve existing behaviour)Backward Compatibility
null(orfalseforgke-standard-clusterto match the previous hardcoded value), so existing configurations are unaffected.Related
modules/beta-autopilot-private-cluster,modules/beta-autopilot-public-cluster,modules/gke-autopilot-cluster