refactor(platform): split addon step for external-dns
This commit is contained in:
parent
18b865d763
commit
a569fe153b
@ -1,4 +1,4 @@
|
|||||||
- name: Install single-node k3s platform addons
|
- name: Addon | single-node k3s platform
|
||||||
hosts: k3s
|
hosts: k3s
|
||||||
user: root
|
user: root
|
||||||
become: yes
|
become: yes
|
||||||
|
|||||||
@ -6,5 +6,12 @@
|
|||||||
tasks:
|
tasks:
|
||||||
- include_role:
|
- include_role:
|
||||||
name: vhosts/k3s_platform_bootstrap
|
name: vhosts/k3s_platform_bootstrap
|
||||||
|
|
||||||
|
- name: Addon | single-node k3s platform
|
||||||
|
hosts: k3s
|
||||||
|
user: root
|
||||||
|
become: yes
|
||||||
|
gather_facts: yes
|
||||||
|
tasks:
|
||||||
- include_role:
|
- include_role:
|
||||||
name: vhosts/k3s_platform_addon
|
name: vhosts/k3s_platform_addon
|
||||||
|
|||||||
@ -0,0 +1,38 @@
|
|||||||
|
- name: Addon | external-dns install chart with retry
|
||||||
|
ansible.builtin.shell: |
|
||||||
|
set -euo pipefail
|
||||||
|
export KUBECONFIG="{{ k3s_platform_kubeconfig_path }}"
|
||||||
|
chart_dir="$(mktemp -d /tmp/external-dns.XXXXXX)"
|
||||||
|
cleanup() {
|
||||||
|
rm -rf "$chart_dir"
|
||||||
|
}
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
attempt=1
|
||||||
|
max_attempts=6
|
||||||
|
while true; do
|
||||||
|
rm -rf "$chart_dir"/*
|
||||||
|
if helm pull --repo "{{ k3s_platform_external_dns_chart_repo_url }}" \
|
||||||
|
--version "{{ k3s_platform_external_dns_chart_version }}" \
|
||||||
|
--untar \
|
||||||
|
--untardir "$chart_dir" \
|
||||||
|
external-dns; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
if [ "$attempt" -ge "$max_attempts" ]; then
|
||||||
|
echo "failed to download external-dns after $attempt attempts" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
sleep "$((attempt * 30))"
|
||||||
|
attempt=$((attempt + 1))
|
||||||
|
done
|
||||||
|
|
||||||
|
helm upgrade --install "{{ k3s_platform_values.components.externalDns.releaseName }}" "$chart_dir/external-dns" \
|
||||||
|
--namespace platform \
|
||||||
|
--create-namespace \
|
||||||
|
--version "{{ k3s_platform_external_dns_chart_version }}" \
|
||||||
|
-f /tmp/platform-external-dns-values.yaml \
|
||||||
|
--wait \
|
||||||
|
--timeout 10m
|
||||||
|
args:
|
||||||
|
executable: /bin/bash
|
||||||
@ -126,43 +126,8 @@
|
|||||||
when:
|
when:
|
||||||
- k3s_platform_values.components.apisix.enabled | default(false)
|
- k3s_platform_values.components.apisix.enabled | default(false)
|
||||||
|
|
||||||
- name: Install external-dns directly with Helm
|
- name: Addon | external-dns
|
||||||
ansible.builtin.shell: |
|
ansible.builtin.import_tasks: addons/external-dns.yml
|
||||||
set -euo pipefail
|
|
||||||
export KUBECONFIG="{{ k3s_platform_kubeconfig_path }}"
|
|
||||||
chart_dir="$(mktemp -d /tmp/external-dns.XXXXXX)"
|
|
||||||
cleanup() {
|
|
||||||
rm -rf "$chart_dir"
|
|
||||||
}
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
attempt=1
|
|
||||||
max_attempts=6
|
|
||||||
while true; do
|
|
||||||
rm -rf "$chart_dir"/*
|
|
||||||
if helm pull --repo "{{ k3s_platform_external_dns_chart_repo_url }}" \
|
|
||||||
--version "{{ k3s_platform_external_dns_chart_version }}" \
|
|
||||||
--untar \
|
|
||||||
--untardir "$chart_dir" \
|
|
||||||
external-dns; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
if [ "$attempt" -ge "$max_attempts" ]; then
|
|
||||||
echo "failed to download external-dns after $attempt attempts" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
sleep "$((attempt * 30))"
|
|
||||||
attempt=$((attempt + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
helm upgrade --install "{{ k3s_platform_values.components.externalDns.releaseName }}" "$chart_dir/external-dns" \
|
|
||||||
--namespace platform \
|
|
||||||
--create-namespace \
|
|
||||||
--version "{{ k3s_platform_external_dns_chart_version }}" \
|
|
||||||
-f /tmp/platform-external-dns-values.yaml \
|
|
||||||
--wait \
|
|
||||||
--timeout 10m
|
|
||||||
args:
|
|
||||||
executable: /bin/bash
|
|
||||||
when:
|
when:
|
||||||
- k3s_platform_values.components.externalDns.enabled | default(false)
|
- k3s_platform_values.components.externalDns.enabled | default(false)
|
||||||
|
tags: [addon, external-dns]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user