From 0121bce9e565b05562a6e4a8851393246e145574 Mon Sep 17 00:00:00 2001 From: Karol Chrapek Date: Tue, 18 Sep 2018 22:13:15 +0200 Subject: [PATCH] Instead of doc update, change the verify step --- docs/upgrades.md | 7 +------ .../preinstall/tasks/0020-verify-settings.yml | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/docs/upgrades.md b/docs/upgrades.md index 5443e067f..8e152230b 100644 --- a/docs/upgrades.md +++ b/docs/upgrades.md @@ -18,11 +18,6 @@ versions. Here are all version vars for each component: * flannel_version * kubedns_version -Please remember that some components upgrade depends on minimum installed version. -In example **calico version 2.6.5 upgrade to 3.1.1 is upgrading etcd store to etcdv3**. -The kubespray stack upgrade would failed when calico version is below 2.6.5. Please check -components' documentation and always upgrade test environment first. - #### Unsafe upgrade example If you wanted to upgrade just kube_version from v1.4.3 to v1.4.6, you could @@ -40,7 +35,7 @@ ansible-playbook cluster.yml -i inventory/sample/hosts.ini -e kube_version=v1.4. #### Graceful upgrade -Kubespray also supports cordon, drain and uncordoning of nodes when performing +Kubespray also supports cordon, drain and uncordoning of nodes when performing a cluster upgrade. There is a separate playbook used for this purpose. It is important to note that upgrade-cluster.yml can only be used for upgrading an existing cluster. That means there must be at least 1 kube-master already diff --git a/roles/kubernetes/preinstall/tasks/0020-verify-settings.yml b/roles/kubernetes/preinstall/tasks/0020-verify-settings.yml index 8c3cec92e..22ac00934 100644 --- a/roles/kubernetes/preinstall/tasks/0020-verify-settings.yml +++ b/roles/kubernetes/preinstall/tasks/0020-verify-settings.yml @@ -127,3 +127,21 @@ tags: - cloud-provider - facts + +- name: "Get current version of calico cluster version" + shell: "{{ bin_dir }}/calicoctl version | grep 'Cluster Version' | awk '{ print $3}'" + register: calico_version_on_server + run_once: yes + delegate_to: "{{ groups['kube-master'][0] }}" + + +- name: "Check that calico version is enought for upgrade" + assert: + that: + - calico_version_on_server.stdout|version_compare('v2.6.5', '>=') + msg: "Your version of calico is not fresh enough for upgrade. Minimum version v2.6.5" + when: + - 'calico_version_on_server.stdout is defined' + - 'calico_version_on_server.stdout != ""' + - inventory_hostname == groups['kube-master'][0] + run_once: yes