Skip to content

feat: add web installer in artifact export func#2905

Open
zuoxuesong-worker wants to merge 1 commit into
kubesphere:mainfrom
zxs-test:feat/artifact-with-web-installer
Open

feat: add web installer in artifact export func#2905
zuoxuesong-worker wants to merge 1 commit into
kubesphere:mainfrom
zxs-test:feat/artifact-with-web-installer

Conversation

@zuoxuesong-worker

Copy link
Copy Markdown
Contributor

feat: add web installer in artifact export func

What type of PR is this?

/kind feature

What this PR does / why we need it:

Now when we create an offline package ,we should use get kk first and generate package.sh file
then exec this sh file to get an package and web-installer
it makes get kk complicated
update kk , add web-installer downloader and pack func

Which issue(s) this PR fixes:

Fixes #

Special notes for reviewers:

add web installer in artifact export func

Does this PR introduced a user-facing change?

add web installer in artifact export func

Additional documentation, usage docs, etc.:


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

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: zuoxuesong-worker

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

The pull request process is described 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

@kubesphere-prow kubesphere-prow Bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 23, 2025
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @zuoxuesong-worker, 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 significantly enhances the artifact export functionality by automating the inclusion of the web installer in offline packages. Previously, users had to follow a multi-step manual process to generate these packages. The changes streamline this workflow by integrating the web installer's download, extraction, and configuration directly into the artifact export playbook, making the process more efficient and user-friendly.

Highlights

  • Streamlined Web Installer Integration: The process for creating offline packages has been significantly simplified by directly integrating the web installer download and packing into the artifact export function, removing the need for manual steps involving kk and shell scripts.
  • New Ansible Role for Web Installer: A dedicated Ansible role download/web-installer has been introduced to handle the downloading, extraction, and initial configuration of the web installer.
  • Centralized Artifact Management: Artifact directory creation and the final packaging logic have been moved to the artifact_export.yaml playbook, ensuring a more cohesive and automated workflow.
  • Configurable Web Installer Download: New default variables have been added to allow explicit control over whether the web installer is downloaded and to specify its source URL.
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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

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 adds functionality to include a web installer in the artifact export process, which is a great feature. My review focuses on improving the implementation by adhering to Ansible best practices. I've suggested replacing shell commands with Ansible's built-in modules like file, copy, archive, get_url, and unarchive. These changes will make the playbooks more idempotent, reliable, and easier to maintain. I also found a minor issue with file permissions that should be corrected.

Comment on lines +32 to +33
command: >-
mkdir -p {{ .artifact_file_dir }}/kubekey/kubekey/

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using the command module with mkdir -p is not idempotent and goes against Ansible best practices. It's better to use the file module to ensure a directory exists. This makes the task more declarative and reliable.

      file:
        path: "{{ .artifact_file_dir }}/kubekey/kubekey/"
        state: directory
        mode: '0755'

Comment on lines +39 to +41
command: |
cp kk {{ .artifact_file_dir }}/
cd {{ .artifact_file_dir }} && tar -czvf {{ .artifact_file }} *

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using command with cp and tar is not idempotent and is less readable than using Ansible's dedicated modules. I suggest refactoring this to use the copy and archive modules. This improves idempotency, error handling, and clarity. I've wrapped them in a block to group the related actions.

      block:
        - name: Artifact | Copy kk binary to artifact dir
          copy:
            src: kk
            dest: "{{ .artifact_file_dir }}/"
            remote_src: yes
        - name: Artifact | Create artifact archive
          archive:
            path: "{{ .artifact_file_dir }}/"
            dest: "{{ .artifact_file }}"
            format: gz

Comment on lines +7 to +9
command: |
curl -L -o {{ .artifact_file_dir }}/web-installer.tgz {{ .download.web_installer.url }}
tar -xzf "{{ .artifact_file_dir }}/web-installer.tgz" --no-same-owner -C {{ .artifact_file_dir }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Instead of using command with curl and tar, it's highly recommended to use the get_url and unarchive modules. These modules are idempotent, provide better error handling, and make the playbook more readable and maintainable. I've replaced the command with a block containing these modules so they share the same when condition.

  block:
    - name: Download web installer
      get_url:
        url: "{{ .download.web_installer.url }}"
        dest: "{{ .artifact_file_dir }}/web-installer.tgz"

    - name: Extract web installer
      unarchive:
        src: "{{ .artifact_file_dir }}/web-installer.tgz"
        dest: "{{ .artifact_file_dir }}"
        remote_src: yes
        extra_opts: --no-same-owner

template:
src: config.json
dest: "{{ .artifact_file_dir }}/schema/config.json"
mode: 0755 No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The config.json file is being created with 0755 permissions, which includes execute permissions for owner, group, and others. For a configuration file, 0644 (rw-r--r--) is more appropriate and secure.

    mode: '0644'

@zuoxuesong-worker zuoxuesong-worker force-pushed the feat/artifact-with-web-installer branch from 73a309c to 736c63b Compare December 24, 2025 02:32
pre_tasks:
- name: Artifact | Set artifact file dir
when:
- .artifact_file | empty | not

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it may be download.artifact_file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

if err := unstructured.SetNestedField(o.Config.Value(), o.Artifact, "artifact_file"); err != nil {

no , it IS artifact_file

post_tasks:
- name: Artifact | Export artifact
when:
- .pack_artifact

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what‘s this

@zuoxuesong-worker zuoxuesong-worker Dec 25, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

artifact file will store in artifact_file_path before pack , add an arg named pack_artifact gave user a choice wheather pack artifact_file or not

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

when user want to make a package with multi version k8s , then user can do

./kk artifact export -c first.yaml --workdir prepare -a $(pwd)/artifact.tgz
./kk artifact export -c second.yaml --workdir prepare -a $(pwd)/artifact.tgz
./kk artifact export -c last.yaml --workdir prepare -a $(pwd)/artifact.tgz --set pack_artifact=true,download.web_installer.download_web_installer=true

kk will download web-installer and make tgz only in the last cmd executed

@zuoxuesong-worker zuoxuesong-worker force-pushed the feat/artifact-with-web-installer branch from 736c63b to 8a978cd Compare December 25, 2025 06:12
Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: add web installer in artifact export func

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: add web installer in artifact export func

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: add web installer in artifact export func

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: add web installer in artifact export func

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: add web installer in artifact export func

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: add web installer in artifact export func

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: add web installer in artifact export func

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: add web installer in artifact export func

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: add web installer in artifact export func

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: add web installer in artifact export func

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: add web installer in artifact export func

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>

feat: add web installer in artifact export func

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>
@zuoxuesong-worker zuoxuesong-worker force-pushed the feat/artifact-with-web-installer branch from 8a978cd to a2d45d5 Compare December 25, 2025 07:49
@kubesphere-prow kubesphere-prow Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 25, 2025
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
2 Security Hotspots

See analysis details on SonarQube Cloud

@redscholar redscholar force-pushed the main branch 2 times, most recently from 6e0b912 to 3c1ecde Compare February 12, 2026 10:01
@ks-ci-bot

Copy link
Copy Markdown
Contributor

PR needs rebase.

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.

@redscholar redscholar force-pushed the main branch 2 times, most recently from cd7b0ad to 6d84ad2 Compare March 12, 2026 03:32
@redscholar redscholar force-pushed the main branch 5 times, most recently from c99b3ec to 88231c5 Compare March 23, 2026 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. needs-rebase 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.

3 participants