Skip to content

Commit

Permalink
chore(ansible): update cluster-rollout-update playbook
Browse files Browse the repository at this point in the history
  • Loading branch information
martinohmann committed Jan 12, 2024
1 parent 74ef438 commit 6795ad0
Showing 1 changed file with 15 additions and 27 deletions.
42 changes: 15 additions & 27 deletions ansible/kubernetes/playbooks/cluster-rollout-update.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# https://github.com/kevincoakley/ansible-role-k8s-rolling-update
# Ref: https://github.com/kevincoakley/ansible-role-k8s-rolling-update
- name: Cluster rollout update
hosts: all
hosts: kubernetes
become: true
gather_facts: true
any_errors_fatal: true
Expand Down Expand Up @@ -33,30 +33,19 @@
delegate_to: "{{ groups['master'][0] }}"

- name: Drain
ansible.builtin.command: "kubectl drain --pod-selector='app!=rook-ceph-osd,app!=csi-attacher,app!=csi-provisioner' --ignore-daemonsets --delete-emptydir-data --force --grace-period=300 {{ inventory_hostname }}"
kubernetes.core.k8s_drain:
name: "{{ inventory_hostname }}"
kubeconfig: /etc/rancher/k3s/k3s.yaml
state: drain
delete_options:
delete_emptydir_data: true
ignore_daemonsets: true
terminate_grace_period: 600
wait_timeout: 900
pod_selectors:
- longhorn.io/component!=share-manager
- longhorn.io/component!=instance-manager
delegate_to: "{{ groups['master'][0] }}"
changed_when: false

### pod_selectors feature in upcoming kubernetes.core 2.5.0 ###
# - name: Drain
# kubernetes.core.k8s_drain:
# name: "{{ inventory_hostname }}"
# kubeconfig: /etc/rancher/k3s/k3s.yaml
# state: drain
# delete_options:
# delete_emptydir_data: true
# ignore_daemonsets: true
# terminate_grace_period: 600
# wait_timeout: 900
# force: true
# pod_selectors:
# # Rook Ceph
# - app!=rook-ceph-osd
# # Longhorn
# - app!=csi-attacher
# # Longhorn
# - app!=csi-provisioner
# delegate_to: "{{ groups['master'][0] }}"

- name: Update
ansible.builtin.apt:
Expand All @@ -72,9 +61,8 @@
when: reboot_required.stat.exists
ansible.builtin.reboot:
msg: Rebooting node
post_reboot_delay: 60
post_reboot_delay: 120
reboot_timeout: 3600
when: reboot_required.stat.exists

- name: Uncordon
kubernetes.core.k8s_drain:
Expand Down

0 comments on commit 6795ad0

Please sign in to comment.