Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update patching playbook to utilize kubernetes.core collection #859

Merged
merged 16 commits into from
Jul 19, 2023
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
9cf9948
Update patching playbook to utilize kubernetes.core collection
PrymalInstynct Jul 18, 2023
4d26909
Update bootstrap/templates/ansible/playbooks/cluster-rollout-update.y…
onedr0p Jul 18, 2023
2311c8d
Merge branch 'onedr0p:main' into ansible_kubernetes_core
PrymalInstynct Jul 18, 2023
11eac1e
address errors found through peer review
PrymalInstynct Jul 18, 2023
faf670d
Update bootstrap/templates/ansible/playbooks/cluster-rollout-update.y…
onedr0p Jul 18, 2023
ffe7cf3
Update bootstrap/templates/ansible/playbooks/cluster-rollout-update.y…
onedr0p Jul 18, 2023
8b1a132
Update bootstrap/templates/ansible/playbooks/cluster-rollout-update.y…
onedr0p Jul 18, 2023
62362f2
Update bootstrap/templates/ansible/playbooks/cluster-rollout-update.y…
PrymalInstynct Jul 18, 2023
a359f08
Update bootstrap/templates/ansible/playbooks/cluster-rollout-update.y…
PrymalInstynct Jul 18, 2023
10af3ef
Merge branch 'onedr0p:main' into ansible_kubernetes_core
PrymalInstynct Jul 19, 2023
32efde9
Updated patching template based on testing
PrymalInstynct Jul 19, 2023
211c71d
Merge branch 'main' into ansible_kubernetes_core
PrymalInstynct Jul 19, 2023
c6be8b1
Update bootstrap/templates/ansible/playbooks/cluster-rollout-update.y…
PrymalInstynct Jul 19, 2023
f76ce1c
Update bootstrap/templates/ansible/playbooks/cluster-rollout-update.y…
onedr0p Jul 19, 2023
969ba3d
Update bootstrap/templates/ansible/playbooks/cluster-rollout-update.y…
onedr0p Jul 19, 2023
1b0c3b9
Update bootstrap/templates/ansible/playbooks/cluster-rollout-update.y…
onedr0p Jul 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,37 @@
- not (kubectl_get_node['stdout'] | from_json).spec.unschedulable is defined
block:
- name: Cordon
ansible.builtin.command: "kubectl cordon {% raw %}{{ inventory_hostname }}{% endraw %}"
kubernetes.core.k8s_drain:
name: "{% raw %}{{ inventory_hostname }}{% endraw %}"
kubeconfig: /etc/rancher/k3s/k3s.yaml
state: cordon
delegate_to: "{% raw %}{{ groups['master'][0] }}{% endraw %}"
changed_when: false

- name: Wait for cordon
ansible.builtin.command: "kubectl get node {% raw %}{{ inventory_hostname }}{% endraw %} -o json"
register: wait_for_cordon
retries: 10
delay: 10
delegate_to: "{% raw %}{{ groups['master'][0] }}{% endraw %}"
changed_when: false
until: (wait_for_cordon['stdout'] | from_json).spec.unschedulable

- name: Drain
ansible.builtin.command: "kubectl drain --ignore-daemonsets --delete-emptydir-data --force {% raw %}{{ inventory_hostname }}{% endraw %}"
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 {% raw %}{{ inventory_hostname }}{% endraw %}"
delegate_to: "{% raw %}{{ groups['master'][0] }}{% endraw %}"
changed_when: false

### pod_selectors feature in upcoming kubernetes.core 2.5.0 ###
# - name: Drain
# kubernetes.core.k8s_drain:
# name: "{% raw %}{{ inventory_hostname }}{% endraw %}"
# 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: "{% raw %}{{ groups['master'][0] }}{% endraw %}"

- name: Update
ansible.builtin.apt:
Expand All @@ -60,16 +74,11 @@
msg: Rebooting node
post_reboot_delay: 60
reboot_timeout: 3600
when: reboot_required.stat.exists

- name: Uncordon
ansible.builtin.command: "kubectl uncordon {% raw %}{{ inventory_hostname }}{% endraw %}"
kubernetes.core.k8s_drain:
name: "{% raw %}{{ inventory_hostname }}{% endraw %}"
kubeconfig: /etc/rancher/k3s/k3s.yaml
state: uncordon
delegate_to: "{% raw %}{{ groups['master'][0] }}{% endraw %}"
changed_when: false

- name: Wait for uncordon
ansible.builtin.command: "kubectl get node {% raw %}{{ inventory_hostname }}{% endraw %} -o json"
retries: 10
delay: 10
delegate_to: "{% raw %}{{ groups['master'][0] }}{% endraw %}"
changed_when: false
until: not (kubectl_get_node['stdout'] | from_json).spec.unschedulable is defined