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
|
||||
user: root
|
||||
become: yes
|
||||
|
||||
@ -6,5 +6,12 @@
|
||||
tasks:
|
||||
- include_role:
|
||||
name: vhosts/k3s_platform_bootstrap
|
||||
|
||||
- name: Addon | single-node k3s platform
|
||||
hosts: k3s
|
||||
user: root
|
||||
become: yes
|
||||
gather_facts: yes
|
||||
tasks:
|
||||
- include_role:
|
||||
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:
|
||||
- k3s_platform_values.components.apisix.enabled | default(false)
|
||||
|
||||
- name: Install external-dns directly with Helm
|
||||
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
|
||||
- name: Addon | external-dns
|
||||
ansible.builtin.import_tasks: addons/external-dns.yml
|
||||
when:
|
||||
- k3s_platform_values.components.externalDns.enabled | default(false)
|
||||
tags: [addon, external-dns]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user