From d9811da95568cbcea492fd322ce2f0c20fcd209b Mon Sep 17 00:00:00 2001 From: przemyslawdy <43173646+przemyslawdy@users.noreply.github.com> Date: Wed, 10 Jul 2019 11:00:11 +0200 Subject: [PATCH] Added kubeadm configuration file for backup and recovery (#340) --- .../src/ansible/roles/backup/tasks/main.yml | 12 ++++++++++ .../src/ansible/roles/recovery/tasks/main.yml | 23 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/core/core/src/ansible/roles/backup/tasks/main.yml b/core/core/src/ansible/roles/backup/tasks/main.yml index b0d391d5c6..582290f177 100644 --- a/core/core/src/ansible/roles/backup/tasks/main.yml +++ b/core/core/src/ansible/roles/backup/tasks/main.yml @@ -42,6 +42,18 @@ --key=/backup/pki/etcd/healthcheck-client.key \ snapshot save /backup/etcd-snapshot.db +- name: Check if kubeadm configuration file exists + stat: + path: /etc/kubeadm/kubeadm-config.yml + register: stat_result + +- name: Backup kubeadm configuration file + copy: + src: /etc/kubeadm/kubeadm-config.yml + dest: "{{ backup_dir }}/tmp" + remote_src: yes + when: stat_result.stat.exists + - name: Set variable with current timestamp set_fact: timestamp="{{ lookup('pipe', 'date +%Y%m%d%H%M%S') }}" diff --git a/core/core/src/ansible/roles/recovery/tasks/main.yml b/core/core/src/ansible/roles/recovery/tasks/main.yml index 48d47ce37a..cea8d59c93 100644 --- a/core/core/src/ansible/roles/recovery/tasks/main.yml +++ b/core/core/src/ansible/roles/recovery/tasks/main.yml @@ -60,8 +60,31 @@ --rm "{{ etcd_image_name.stdout }}" \ /bin/sh -c "etcdctl snapshot restore '/backup/etcd-snapshot.db'; mv /default.etcd/member/ /var/lib/etcd/" +- name: Check if kubeadm configuration file exists + stat: + path: "{{ backup_dir }}/tmp/kubeadm-config.yml" + register: stat_result + +- name: Create directory for kubeadm configuration file + file: + path: /etc/kubeadm + state: directory + when: stat_result.stat.exists + +- name: Restore kubeadm configuration file + copy: + src: "{{ backup_dir }}/tmp/kubeadm-config.yml" + dest: "/etc/kubeadm/kubeadm-config.yml" + remote_src: yes + when: stat_result.stat.exists + +- name: Initialize the master with backup including kubeadm configuration file + shell: kubeadm init --ignore-preflight-errors=DirAvailable--var-lib-etcd,NumCPU --config /etc/kubeadm/kubeadm-config.yml + when: stat_result.stat.exists + - name: Initialize the master with backup shell: kubeadm init --ignore-preflight-errors=DirAvailable--var-lib-etcd,NumCPU + when: not stat_result.stat.exists - name: Wait for all nodes to be ready environment: