From 1d4e6b2ade2a33e57f9aa57296d274496e0f37f6 Mon Sep 17 00:00:00 2001 From: Matthew Mosesohn Date: Mon, 27 Mar 2017 14:44:21 +0300 Subject: [PATCH] delete master containers forcefully --- roles/kubernetes/master/handlers/main.yml | 2 +- roles/kubernetes/master/tasks/pre-upgrade.yml | 22 ++++++++++--------- tests/templates/inventory-gce.j2 | 2 ++ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/roles/kubernetes/master/handlers/main.yml b/roles/kubernetes/master/handlers/main.yml index 38edeeb1f..1eb5a4886 100644 --- a/roles/kubernetes/master/handlers/main.yml +++ b/roles/kubernetes/master/handlers/main.yml @@ -26,7 +26,7 @@ url: http://localhost:10251/healthz register: scheduler_result until: scheduler_result.status == 200 - retries: 15 + retries: 60 delay: 5 - name: Master | wait for kube-controller-manager diff --git a/roles/kubernetes/master/tasks/pre-upgrade.yml b/roles/kubernetes/master/tasks/pre-upgrade.yml index 12b270421..35d573e97 100644 --- a/roles/kubernetes/master/tasks/pre-upgrade.yml +++ b/roles/kubernetes/master/tasks/pre-upgrade.yml @@ -55,11 +55,10 @@ set_fact: needs_etcd_migration: "{{ kube_apiserver_storage_backend == 'etcd3' and data_migrated.stdout_lines|length == 0 and old_data_exists.rc == 0 }}" -- name: "Pre-upgrade | Write invalid image to master manifests on all kube-masters" - replace: - dest: "/etc/kubernetes/manifests/{{item[1]}}.manifest" - regexp: '(\s+)image:\s+.*?$' - replace: '\1image: kill.apiserver.using.fake.image.in:manifest' +- name: "Pre-upgrade | Delete master manifests on all kube-masters" + file: + path: "/etc/kubernetes/manifests/{{item[1]}}.manifest" + state: absent delegate_to: "{{item[0]}}" with_nested: - "{{groups['kube-master']}}" @@ -67,11 +66,14 @@ register: kube_apiserver_manifest_replaced when: (secret_changed|default(false) or etcd_secret_changed|default(false) or needs_etcd_migration|bool) and kube_apiserver_manifest.stat.exists -- name: "Pre-upgrade | Pause while waiting for kubelet to delete kube-apiserver pod" - pause: - seconds: 20 - when: kube_apiserver_manifest_replaced.changed - tags: kube-apiserver +- name: "Pre-upgrade | Delete master containers forcefully on all kube-masters" + shell: "docker ps -f name=k8s-{{item}}* -q | xargs --no-run-if-empty docker rm -f" + delegate_to: "{{item[0]}}" + with_nested: + - "{{groups['kube-master']}}" + - ["kube-apiserver", "kube-controller-manager", "kube-scheduler"] + register: kube_apiserver_manifest_replaced + when: (secret_changed|default(false) or etcd_secret_changed|default(false) or needs_etcd_migration|bool) and kube_apiserver_manifest.stat.exists - name: "Pre-upgrade | etcd3 upgrade | stop etcd" service: diff --git a/tests/templates/inventory-gce.j2 b/tests/templates/inventory-gce.j2 index d58f6896c..c77556f0b 100644 --- a/tests/templates/inventory-gce.j2 +++ b/tests/templates/inventory-gce.j2 @@ -27,10 +27,12 @@ {{node3}} [etcd] +{{node1}} {{node2}} {{node3}} [vault] +{{node1}} {{node2}} {{node3}} {% else %}