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

Added kubeadm configuration file for backup and recovery #340

Merged
merged 1 commit into from
Jul 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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