Files
home-cluster/bootstrap/templates/ansible/playbooks/cluster-rollout-update.yaml.j2
T
Devin Buhl afbf097dac feat: update kube-vip ansible playbook for k0s and k3s - ipv6 config changes (#1234)
* feat: update kube-vip ansible playbook for k0s and k3s

Signed-off-by: Devin Buhl <devin@buhl.casa>

* fix: update renovate

Signed-off-by: Devin Buhl <devin@buhl.casa>

* fix: move ipv6 to advanced options

Signed-off-by: Devin Buhl <devin@buhl.casa>

* feat: kube-vip manifests to partials

Signed-off-by: Devin Buhl <devin@buhl.casa>

* feat: kube vip samesies

Signed-off-by: Devin Buhl <devin@buhl.casa>

* fix: update config sample

Signed-off-by: Devin Buhl <devin@buhl.casa>

---------

Signed-off-by: Devin Buhl <devin@buhl.casa>
2024-01-22 15:28:21 -05:00

91 lines
3.1 KiB
YAML

#% if bootstrap_distribution in ['k0s', 'k3s'] %#
---
# https://github.com/kevincoakley/ansible-role-k8s-rolling-update
- name: Cluster rollout update
hosts: kubernetes
become: true
gather_facts: true
any_errors_fatal: true
serial: 1
pre_tasks:
- name: Pausing for 5 seconds...
ansible.builtin.pause:
seconds: 5
tasks:
- name: Details
#% if bootstrap_distribution in ['k3s'] %#
ansible.builtin.command: "k3s kubectl get node {{ inventory_hostname }} -o json"
#% elif bootstrap_distribution in ['k0s'] %#
ansible.builtin.command: "k0s kubectl get node {{ inventory_hostname }} -o json"
#% endif %#
register: kubectl_get_node
delegate_to: "{{ groups['master'][0] }}"
failed_when: false
changed_when: false
- name: Update
when:
# When status.conditions[x].type == Ready then check stats.conditions[x].status for True|False
- kubectl_get_node['stdout'] | from_json | json_query("status.conditions[?type == 'Ready'].status")
# If spec.unschedulable is defined then the node is cordoned
- not (kubectl_get_node['stdout'] | from_json).spec.unschedulable is defined
block:
- name: Cordon
kubernetes.core.k8s_drain:
name: "{{ inventory_hostname }}"
#% if bootstrap_distribution in ['k3s'] %#
kubeconfig: /etc/rancher/k3s/k3s.yaml
#% elif bootstrap_distribution in ['k0s'] %#
kubeconfig: /var/lib/k0s/pki/admin.conf
#% endif %#
state: cordon
delegate_to: "{{ groups['master'][0] }}"
- name: Drain
kubernetes.core.k8s_drain:
name: "{{ inventory_hostname }}"
#% if bootstrap_distribution in ['k3s'] %#
kubeconfig: /etc/rancher/k3s/k3s.yaml
#% elif bootstrap_distribution in ['k0s'] %#
kubeconfig: /var/lib/k0s/pki/admin.conf
#% endif %#
state: drain
delete_options:
delete_emptydir_data: true
ignore_daemonsets: true
terminate_grace_period: 600
wait_timeout: 900
pod_selectors:
# Rook Ceph
- app!=rook-ceph-osd
delegate_to: "{{ groups['master'][0] }}"
- name: Update
ansible.builtin.apt:
upgrade: dist
update_cache: true
- name: Check if reboot is required
ansible.builtin.stat:
path: /var/run/reboot-required
register: reboot_required
- name: Reboot
when: reboot_required.stat.exists
ansible.builtin.reboot:
msg: Rebooting node
post_reboot_delay: 60
reboot_timeout: 3600
- name: Uncordon
kubernetes.core.k8s_drain:
name: "{{ inventory_hostname }}"
#% if bootstrap_distribution in ['k3s'] %#
kubeconfig: /etc/rancher/k3s/k3s.yaml
#% elif bootstrap_distribution in ['k0s'] %#
kubeconfig: /var/lib/k0s/pki/admin.conf
#% endif %#
state: uncordon
delegate_to: "{{ groups['master'][0] }}"
#% endif %#