From cf3f7338289cc50b31e9c4ee666cfeb339eb6c50 Mon Sep 17 00:00:00 2001 From: Spencer Smith Date: Fri, 9 Dec 2016 10:44:52 -0800 Subject: [PATCH] first cut of an upgrade process --- roles/upgrade/post-upgrade/tasks/main.yml | 5 ++++ roles/upgrade/pre-upgrade/tasks/main.yml | 12 +++++++++ upgrade-cluster.yml | 33 +++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 roles/upgrade/post-upgrade/tasks/main.yml create mode 100644 roles/upgrade/pre-upgrade/tasks/main.yml create mode 100644 upgrade-cluster.yml diff --git a/roles/upgrade/post-upgrade/tasks/main.yml b/roles/upgrade/post-upgrade/tasks/main.yml new file mode 100644 index 000000000..b576b0947 --- /dev/null +++ b/roles/upgrade/post-upgrade/tasks/main.yml @@ -0,0 +1,5 @@ +--- + +- name: Uncordon node + command: kubectl uncordon {{ ansible_hostname }} + delegate_to: "{{ groups['kube-master'][0] }}" diff --git a/roles/upgrade/pre-upgrade/tasks/main.yml b/roles/upgrade/pre-upgrade/tasks/main.yml new file mode 100644 index 000000000..25f665a86 --- /dev/null +++ b/roles/upgrade/pre-upgrade/tasks/main.yml @@ -0,0 +1,12 @@ +--- + +- name: Cordon node + command: kubectl cordon {{ ansible_hostname }} + delegate_to: "{{ groups['kube-master'][0] }}" + +- name: Drain node + command: kubectl drain --force --ignore-daemonsets --delete-local-data {{ ansible_hostname }} + delegate_to: "{{ groups['kube-master'][0] }}" + +- name: Sleep for grace period for draining + pause: seconds=30 \ No newline at end of file diff --git a/upgrade-cluster.yml b/upgrade-cluster.yml new file mode 100644 index 000000000..d7089fc49 --- /dev/null +++ b/upgrade-cluster.yml @@ -0,0 +1,33 @@ +--- +- hosts: all + any_errors_fatal: true + gather_facts: true + +- hosts: all:!network-storage + any_errors_fatal: true + roles: + - { role: kubernetes/preinstall, tags: preinstall } + +- hosts: etcd:!k8s-cluster + any_errors_fatal: true + serial: 1 + roles: + - { role: etcd, tags: etcd } + +- hosts: kube-node + any_errors_fatal: true + serial: 1 + roles: + - { role: etcd, tags: etcd } + - { role: upgrade/pre-upgrade, tags: upgrade/pre-upgrade } + - { role: kubernetes/node, tags: node } + - { role: network_plugin, tags: network } + - { role: upgrade/post-upgrade, tags: upgrade/post-upgrade } + +- hosts: kube-master + any_errors_fatal: true + serial: 1 + roles: + - { role: etcd, tags: etcd } + - { role: kubernetes/node, tags: node } + - { role: kubernetes/master, tags: master } \ No newline at end of file