feat(helm): clusters update
这个提交包含在:
@@ -13,6 +13,7 @@ ha_server_url: "{{ lookup('env', 'HA_SERVER_URL') | default('', true) }}"
|
||||
# K3s Server URL (优先使用 HA_SERVER_URL,否则动态使用 init 节点地址)
|
||||
k3s_server_url: "{{ ha_server_url if (ha_server_url | length > 0) else '' }}"
|
||||
k3s_version: "v1.34.2+k3s1"
|
||||
tailscale_version: "1.96.4"
|
||||
|
||||
# ETCD 配置
|
||||
etcd_snapshot_retention: 1
|
||||
@@ -44,4 +45,3 @@ registry_mirrors:
|
||||
- "k8s.m.daocloud.io"
|
||||
quay.io:
|
||||
- "quay.m.daocloud.io"
|
||||
|
||||
|
||||
@@ -167,3 +167,37 @@
|
||||
{{ nodes.stdout }}
|
||||
══════════════════════════════════════════════════════════════
|
||||
when: cluster_init | default(false)
|
||||
|
||||
# ============================================
|
||||
# K3s 卸载 (需显式指定: --tags uninstall)
|
||||
# ============================================
|
||||
- name: Uninstall K3s agents
|
||||
hosts: agents
|
||||
gather_facts: false
|
||||
tags: [uninstall, never]
|
||||
tasks:
|
||||
- name: Check agent uninstall script
|
||||
ansible.builtin.stat:
|
||||
path: /usr/local/bin/k3s-agent-uninstall.sh
|
||||
register: agent_uninstall_script
|
||||
|
||||
- name: Run k3s-agent-uninstall.sh
|
||||
ansible.builtin.command: /usr/local/bin/k3s-agent-uninstall.sh
|
||||
when: agent_uninstall_script.stat.exists
|
||||
changed_when: true
|
||||
|
||||
- name: Uninstall K3s masters
|
||||
hosts: masters
|
||||
gather_facts: false
|
||||
serial: 1
|
||||
tags: [uninstall, never]
|
||||
tasks:
|
||||
- name: Check server uninstall script
|
||||
ansible.builtin.stat:
|
||||
path: /usr/local/bin/k3s-uninstall.sh
|
||||
register: server_uninstall_script
|
||||
|
||||
- name: Run k3s-uninstall.sh
|
||||
ansible.builtin.command: /usr/local/bin/k3s-uninstall.sh
|
||||
when: server_uninstall_script.stat.exists
|
||||
changed_when: true
|
||||
|
||||
@@ -37,6 +37,20 @@
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
|
||||
- name: Check current Tailscale version
|
||||
ansible.builtin.shell: tailscale version | head -1
|
||||
register: common_tailscale_version
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
when: common_tailscale_check.rc == 0
|
||||
|
||||
- name: Set Tailscale install flag
|
||||
ansible.builtin.set_fact:
|
||||
tailscale_needs_install: "{{
|
||||
common_tailscale_check.rc != 0 or
|
||||
(common_tailscale_version.stdout | default('') is not search(tailscale_version))
|
||||
}}"
|
||||
|
||||
- name: Download Tailscale install script
|
||||
ansible.builtin.get_url:
|
||||
url: https://tailscale.com/install.sh
|
||||
@@ -44,11 +58,20 @@
|
||||
mode: "0755"
|
||||
when: common_tailscale_check.rc != 0
|
||||
|
||||
- name: Install Tailscale
|
||||
- name: Install Tailscale via install script
|
||||
ansible.builtin.command: /tmp/tailscale-install.sh
|
||||
when: common_tailscale_check.rc != 0
|
||||
changed_when: true
|
||||
|
||||
- name: Install specific Tailscale version
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- "tailscale={{ tailscale_version }}"
|
||||
- "tailscaled={{ tailscale_version }}"
|
||||
state: present
|
||||
allow_downgrade: true
|
||||
when: tailscale_needs_install
|
||||
|
||||
- name: Remove Tailscale install script
|
||||
ansible.builtin.file:
|
||||
path: /tmp/tailscale-install.sh
|
||||
|
||||
@@ -110,7 +110,7 @@
|
||||
- name: Wait for K3s server ready
|
||||
ansible.builtin.wait_for:
|
||||
path: /var/lib/rancher/k3s/server/node-token
|
||||
timeout: 120
|
||||
timeout: 300
|
||||
when: "'masters' in group_names"
|
||||
|
||||
# 保存 kubeconfig (仅 cluster-init)
|
||||
|
||||
在新议题中引用
屏蔽一个用户