Skip to content

Commit

Permalink
Added kubeadm configuration file for backup and recovery (hitachiener…
Browse files Browse the repository at this point in the history
  • Loading branch information
przemyslavic authored Jul 10, 2019
1 parent f1d038d commit d9811da
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
12 changes: 12 additions & 0 deletions core/core/src/ansible/roles/backup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}"

Expand Down
23 changes: 23 additions & 0 deletions core/core/src/ansible/roles/recovery/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit d9811da

Please sign in to comment.