From a2d45d55358b6f3247a03f1b193204f7f621f9ae Mon Sep 17 00:00:00 2001 From: "xuesongzuo@yunify.com" Date: Tue, 23 Dec 2025 10:52:41 +0800 Subject: [PATCH] feat: add web installer in artifact export func Signed-off-by: xuesongzuo@yunify.com feat: add web installer in artifact export func Signed-off-by: xuesongzuo@yunify.com feat: add web installer in artifact export func Signed-off-by: xuesongzuo@yunify.com feat: add web installer in artifact export func Signed-off-by: xuesongzuo@yunify.com feat: add web installer in artifact export func Signed-off-by: xuesongzuo@yunify.com feat: add web installer in artifact export func Signed-off-by: xuesongzuo@yunify.com feat: add web installer in artifact export func Signed-off-by: xuesongzuo@yunify.com feat: add web installer in artifact export func Signed-off-by: xuesongzuo@yunify.com feat: add web installer in artifact export func Signed-off-by: xuesongzuo@yunify.com feat: add web installer in artifact export func Signed-off-by: xuesongzuo@yunify.com feat: add web installer in artifact export func Signed-off-by: xuesongzuo@yunify.com feat: add web installer in artifact export func Signed-off-by: xuesongzuo@yunify.com feat: add web installer in artifact export func Signed-off-by: xuesongzuo@yunify.com --- builtin/core/playbooks/artifact_export.yaml | 24 ++++++++++++++- builtin/core/roles/copy/tasks/main.yaml | 14 --------- .../core/roles/defaults/vars/10-download.yaml | 4 +++ .../files/install-1.2.1-20251212.yaml | 26 +++++++++++++++++ .../files/install-1.2.3-20251118.yaml | 26 +++++++++++++++++ .../download/web-installer/tasks/main.yaml | 29 +++++++++++++++++++ .../web-installer/templates/config.json | 17 +++++++++++ 7 files changed, 125 insertions(+), 15 deletions(-) create mode 100644 builtin/core/roles/download/web-installer/files/install-1.2.1-20251212.yaml create mode 100644 builtin/core/roles/download/web-installer/files/install-1.2.3-20251118.yaml create mode 100644 builtin/core/roles/download/web-installer/tasks/main.yaml create mode 100644 builtin/core/roles/download/web-installer/templates/config.json diff --git a/builtin/core/playbooks/artifact_export.yaml b/builtin/core/playbooks/artifact_export.yaml index 5495b5cd..0aa57c36 100644 --- a/builtin/core/playbooks/artifact_export.yaml +++ b/builtin/core/playbooks/artifact_export.yaml @@ -16,4 +16,26 @@ roles: - download - copy - + - role: download/web-installer + when: + - .download.web_installer.download_web_installer + pre_tasks: + - name: Artifact | Set artifact file dir + when: + - .artifact_file | empty | not + set_fact: + artifact_file_dir: >- + {{ .artifact_file | dir }}/artifact + - name: Artifact | Create artifact dir + when: + - .artifact_file_dir | empty | not + command: >- + mkdir -p {{ .artifact_file_dir }}/kubekey/kubekey/ + post_tasks: + - name: Artifact | Export artifact + when: + - .pack_artifact + - .artifact_file_dir | empty | not + command: | + cp kk {{ .artifact_file_dir }}/ + cd {{ .artifact_file_dir }} && tar -czvf {{ .artifact_file }} * diff --git a/builtin/core/roles/copy/tasks/main.yaml b/builtin/core/roles/copy/tasks/main.yaml index 5b911d09..d987c045 100644 --- a/builtin/core/roles/copy/tasks/main.yaml +++ b/builtin/core/roles/copy/tasks/main.yaml @@ -1,15 +1,4 @@ --- -- name: Copy | Set artifact file dir - when: - - .artifact_file | empty | not - set_fact: - artifact_file_dir: >- - {{ .artifact_file | dir }}/artifact - -- name: Copy | Create artifact file dir - command: >- - mkdir -p {{ .artifact_file_dir }}/kubekey/kubekey/ - - name: Artifact | Copy required binaries and images when: .artifact_file_dir | empty | not block: @@ -23,6 +12,3 @@ tags: ["kubernetes", "image_registry"] - include_tasks: iso.yaml -- name: Export artifact - command: | - cd {{ .artifact_file_dir }} && tar -czvf {{ .artifact_file }} * diff --git a/builtin/core/roles/defaults/vars/10-download.yaml b/builtin/core/roles/defaults/vars/10-download.yaml index 6671c3fa..165155a5 100644 --- a/builtin/core/roles/defaults/vars/10-download.yaml +++ b/builtin/core/roles/defaults/vars/10-download.yaml @@ -217,6 +217,10 @@ download: nfs_provisioner: https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/releases/download/nfs-subdir-external-provisioner-4.0.18/nfs-subdir-external-provisioner-{{ .storage_class.nfs_provisioner_version }}.tgz download_image: false download_iso: false + web_installer: + download_web_installer: false + url: >- + https://kubekey.pek3b.qingstor.com/github.com/kubesphere/web-installer/releases/latest/download/web-installer.tgz iso_url: base_path: >- {{- if .download.zone | eq "cn" -}} diff --git a/builtin/core/roles/download/web-installer/files/install-1.2.1-20251212.yaml b/builtin/core/roles/download/web-installer/files/install-1.2.1-20251212.yaml new file mode 100644 index 00000000..a0bc2e26 --- /dev/null +++ b/builtin/core/roles/download/web-installer/files/install-1.2.1-20251212.yaml @@ -0,0 +1,26 @@ +- hosts: + - kube_control_plane[0] + vars_files: + - vars/kubesphere.yaml + tasks: + - name: Copy KubeSphere Helm package to remote host + copy: + src: ks-core.tgz + dest: /etc/kubesphere/ks-core.tgz + - name: Generate values file from schema + run_once: true + copy: + content: >- + {{ index . "ks-core" | toYaml }} + dest: >- + /etc/kubesphere/value.yaml + - name: Deploy or upgrade KubeSphere using Helm + command: | + helm upgrade --install --wait --create-namespace --namespace kubesphere-system -f /etc/kubesphere/value.yaml \ + ks-core /etc/kubesphere/ks-core.tgz --reset-values \ + --set telemetry.posthog.storage.type=pvc,telemetry.posthog.storage.pvc.resources.requests.storage=10Gi + - name: Output KubeSphere console access information + result: + address: http://{{ .internal_ipv4 }}:30880 + user: admin + password: P@88w0rd diff --git a/builtin/core/roles/download/web-installer/files/install-1.2.3-20251118.yaml b/builtin/core/roles/download/web-installer/files/install-1.2.3-20251118.yaml new file mode 100644 index 00000000..a0bc2e26 --- /dev/null +++ b/builtin/core/roles/download/web-installer/files/install-1.2.3-20251118.yaml @@ -0,0 +1,26 @@ +- hosts: + - kube_control_plane[0] + vars_files: + - vars/kubesphere.yaml + tasks: + - name: Copy KubeSphere Helm package to remote host + copy: + src: ks-core.tgz + dest: /etc/kubesphere/ks-core.tgz + - name: Generate values file from schema + run_once: true + copy: + content: >- + {{ index . "ks-core" | toYaml }} + dest: >- + /etc/kubesphere/value.yaml + - name: Deploy or upgrade KubeSphere using Helm + command: | + helm upgrade --install --wait --create-namespace --namespace kubesphere-system -f /etc/kubesphere/value.yaml \ + ks-core /etc/kubesphere/ks-core.tgz --reset-values \ + --set telemetry.posthog.storage.type=pvc,telemetry.posthog.storage.pvc.resources.requests.storage=10Gi + - name: Output KubeSphere console access information + result: + address: http://{{ .internal_ipv4 }}:30880 + user: admin + password: P@88w0rd diff --git a/builtin/core/roles/download/web-installer/tasks/main.yaml b/builtin/core/roles/download/web-installer/tasks/main.yaml new file mode 100644 index 00000000..aa192501 --- /dev/null +++ b/builtin/core/roles/download/web-installer/tasks/main.yaml @@ -0,0 +1,29 @@ +--- +- name: WebInstaller | Download web installer + when: + - .download.web_installer.download_web_installer + - .download.web_installer.url | empty | not + - .artifact_file_dir | empty | not + 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 }} + +- name: WebInstaller | Set Ks Core + when: + - .download.kse_chart_version | empty | not + block: + - name: WebInstaller | Download ks core chart + command: | + helm pull oci://hub.kubesphere.com.cn/kse/ks-core --version {{ .download.kse_chart_version }} -d {{ .artifact_file_dir }}/kubesphere/playbooks/files/ + mv {{ .artifact_file_dir }}/kubesphere/playbooks/files/ks-core-{{ .download.kse_chart_version }}.tgz {{ .artifact_file_dir }}/kubesphere/playbooks/files/ks-core.tgz + - name: WebInstaller | Set ks core install task + copy: + src: "install-{{ .download.kse_chart_version }}.yaml" + dest: "{{ .artifact_file_dir }}/kubesphere/playbooks/install.yaml" + +- name: WebInstaller | Init config json + when: + - .artifact_file_dir | empty | not + template: + src: config.json + dest: "{{ .artifact_file_dir }}/schema/config.json" diff --git a/builtin/core/roles/download/web-installer/templates/config.json b/builtin/core/roles/download/web-installer/templates/config.json new file mode 100644 index 00000000..4b765bfe --- /dev/null +++ b/builtin/core/roles/download/web-installer/templates/config.json @@ -0,0 +1,17 @@ +{ + "kubernetes.json": { + "kubernetes": { + "kube_version": "{{ .kubernetes.kube_version }}", + "control_plane_endpoint": { + "host": "lb.kubesphere.local", + "port": 6443, + "type": "local" + } + }, + "cri": { +{{- if .cri.container_manager | empty | not }} + "container_manager": "{{ .cri.container_manager }}" +{{- end }} + } + } +} \ No newline at end of file