From 3f24a4af1ae7b635d288cfd50c3e4fc4f749c1e6 Mon Sep 17 00:00:00 2001 From: Danny Bessems Date: Tue, 3 Jan 2023 11:28:32 +0100 Subject: [PATCH] Add graceful shutdown configuration --- .../roles/metacluster/tasks/k3s.yml | 21 ++++++++++++++++++- ansible/vars/metacluster.yml | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ansible/roles/firstboot/files/ansible_payload/roles/metacluster/tasks/k3s.yml b/ansible/roles/firstboot/files/ansible_payload/roles/metacluster/tasks/k3s.yml index f6141f6..69bd55c 100644 --- a/ansible/roles/firstboot/files/ansible_payload/roles/metacluster/tasks/k3s.yml +++ b/ansible/roles/firstboot/files/ansible_payload/roles/metacluster/tasks/k3s.yml @@ -1,3 +1,22 @@ +- name: Store custom configuration files + ansible.builtin.copy: + dest: "{{ item.filename }}" + content: "{{ item.content }}" + loop: + - filename: /etc/rancher/k3s/config.yaml + content: | + kubelet-arg: + - "config=/etc/rancher/k3s/kubelet.config" + - filename: /etc/rancher/k3s/kubelet.config + content: | + apiVersion: kubelet.config.k8s.io/v1beta1 + kind: KubeletConfiguration + + shutdownGracePeriod: 180s + shtudownGracePeriodCriticalPods: 60s + loop_control: + label: "{{ item.filename }}" + - name: Gather service facts ansible.builtin.service_facts: # Module requires no attributes @@ -8,7 +27,7 @@ chdir: /opt/metacluster/k3s environment: INSTALL_K3S_SKIP_DOWNLOAD: 'true' - INSTALL_K3S_EXEC: 'server --cluster-init --disable local-storage' + INSTALL_K3S_EXEC: 'server --cluster-init --disable local-storage --config /etc/rancher/k3s/config.yaml' when: ansible_facts.services['k3s.service'] is undefined - name: Debug possible taints on k3s node diff --git a/ansible/vars/metacluster.yml b/ansible/vars/metacluster.yml index 2ed2cb6..a915e69 100644 --- a/ansible/vars/metacluster.yml +++ b/ansible/vars/metacluster.yml @@ -154,6 +154,7 @@ components: parse_logic: cat values.yaml | yq eval '.. | select(has("repository")) | .repository + ":" + .tag' chart_values: !unsafe | defaultSettings: + allowNodeDrainWithLastHealthyReplica: true defaultDataPath: /mnt/blockstorage defaultReplicaCount: 1 ingress: