Skip to content

Conversation

@will4j
Copy link
Contributor

@will4j will4j commented Dec 24, 2025

What type of PR is this?

/kind feature

What this PR does / why we need it:

According to this k8s doc, the main change of kubeadm Configuration (v1beta4) is Replace the existing string/string extra argument maps with structured extra arguments that support duplicates. The change applies to ClusterConfiguration - apiServer.extraArgs, controllerManager.extraArgs, scheduler.extraArgs, etcd.local.extraArgs. Also to nodeRegistration.kubeletExtraArgs.

so I add a template function to convert extraArgs config from map to slice, keep kubekey config schema unchanged.

and use v1beta4 when kube version greater than v1.31.0

Which issue(s) this PR fixes:

Fixes #

Special notes for reviewers:

Does this PR introduced a user-facing change?

Use kubeadm Configuration (v1beta4) when kube version higher than v1.31.0

Additional documentation, usage docs, etc.:


Signed-off-by: William Wang <[email protected]>
as now kubekey config only support map as extraArgs

Signed-off-by: William Wang <[email protected]>
@kubesphere-prow
Copy link

This PR has multiple commits, and the default merge method is: squash.
You can request commits to be merged using the label: tide/merge-method-merge

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@kubesphere-prow kubesphere-prow bot added release-note kind/feature Categorizes issue or PR as related to a new feature. labels Dec 24, 2025
@kubesphere-prow
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: will4j
Once this PR has been reviewed and has the lgtm label, please assign pixiake for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@gemini-code-assist
Copy link

Summary of Changes

Hello @will4j, 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 upgrades the kubeadm configuration API version to v1beta4 for Kubernetes clusters running version v1.31.0 and higher. This change is crucial for maintaining compatibility with newer Kubernetes releases, as v1beta4 introduces a more structured way to define extraArgs for various control plane components. The update ensures that cluster initialization and node joining processes correctly apply configurations using the latest API, while also providing a conversion mechanism for existing extraArgs formats.

Highlights

  • Kubeadm API Version Upgrade: Introduced support for kubeadm Configuration API v1beta4 for Kubernetes versions v1.31.0 and above, aligning with the latest Kubernetes API specifications.
  • Structured Extra Arguments: Implemented a new template function kubeExtraArgs to convert map-based extraArgs configurations into the structured slice-of-maps format required by kubeadm-config.v1beta4 for components like apiServer, controllerManager, scheduler, etcd, and kubelet.
  • New Kubeadm Templates: Added dedicated kubeadm-init.v1beta4 and kubeadm-join.v1beta4 templates to handle the new API version's configuration structure for both cluster initialization and node joining processes.
  • Conditional Template Usage: Updated the Ansible tasks to dynamically select the appropriate kubeadm configuration template (v1beta2, v1beta3, or v1beta4) based on the detected Kubernetes version.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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

  1. 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.

@kubesphere-prow kubesphere-prow bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 24, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a 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 support for kubeadm configuration v1beta4, which is used for Kubernetes versions v1.31.0 and higher. This involves adding new templates for kubeadm-init and kubeadm-join, and a new Go template function kubeExtraArgs to convert extraArgs from a map to the new structured list format required by v1beta4. The changes look good overall. I've made a couple of suggestions: one to improve the implementation of the new kubeExtraArgs function for better performance and robustness, and another to fix a minor style issue in the new template file.

@will4j will4j force-pushed the kubeadm-conf-v1beta4 branch from 673ed29 to b7d1c9b Compare December 24, 2025 05:37
value: /etc/kubernetes/audit/webhook.yaml
{{- end }}
{{- if .kubernetes.apiserver.extra_args | empty | not }}
{{ kubeExtraArgs .kubernetes.apiserver.extra_args | toYaml | indent 4 }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Good!!! Please help update kubeadm-init.v1beta2, kubeadm-init.v1beta3, kubeadm-join.v1beta2, and kubeadm-join.v1beta3 accordingly.

Copy link
Contributor

@redscholar redscholar Dec 25, 2025

Choose a reason for hiding this comment

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

@will4j
image
The configuration for v3 is as follows; would it be better to retain this format?
like:

kubernetes:
  apiserver:
    extra_args:
      - name: xxx
        value: xxx

Copy link
Contributor Author

@will4j will4j Dec 25, 2025

Choose a reason for hiding this comment

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

I was intend to support both string/string format and NamedString format before. but extra_args in kubkey config default value (in builtin roles defaults) is type map, use NamedString will cause schema un match when merge kubekey config in playbook run. so I think it be better to keep use string/string format in kubekey config file for all versions. and convert to what it needed accordingly, which means, config unchanged as

kubernetes:
  apiserver:
    extra_args:
      - name: value

and only convert to NamedString in kubeadm v1beta4 like

apiServer:
  extraArgs:
    - name: xxx
      value: xxx

So kubekey config, kubeadm-init.v1beta2, kubeadm-init.v1beta3 etc are unchanged in this case.

Copy link
Contributor Author

@will4j will4j Dec 25, 2025

Choose a reason for hiding this comment

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

I am not sure if it is a good idea to make breaking change to use NamedString format in kubekey config, like

kubernetes:
  apiserver:
    extra_args:
      - name: xxx
        value: xxx

although this can support new features in v1beta4 of support duplicates.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
26.3% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Categorizes issue or PR as related to a new feature. release-note size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants