From 2d1109e09ebf6948ca48870a9760767228a1abcf Mon Sep 17 00:00:00 2001 From: Matthew Mosesohn Date: Wed, 8 Feb 2017 17:13:17 +0300 Subject: [PATCH] Fix upgrade for all daemonset type resources Daemonsets cannot be simply upgraded through a single API call, regardless of any kubectl documentation. The resource must be purged and then recreated in order to make any changes. --- .../kubernetes-apps/ansible/tasks/netchecker.yml | 12 ++++++++++++ roles/kubernetes-apps/efk/fluentd/tasks/main.yml | 13 ++++++++++++- .../network_plugin/canal/tasks/main.yaml | 15 +++++++++++++++ .../network_plugin/weave/tasks/main.yml | 13 +++++++++++++ roles/network_plugin/canal/tasks/main.yml | 1 + 5 files changed, 53 insertions(+), 1 deletion(-) diff --git a/roles/kubernetes-apps/ansible/tasks/netchecker.yml b/roles/kubernetes-apps/ansible/tasks/netchecker.yml index c28d921b6..0413e4bb6 100644 --- a/roles/kubernetes-apps/ansible/tasks/netchecker.yml +++ b/roles/kubernetes-apps/ansible/tasks/netchecker.yml @@ -8,6 +8,18 @@ register: manifests when: inventory_hostname == groups['kube-master'][0] +#FIXME: remove if kubernetes/features#124 is implemented +- name: Kubernetes Apps | Purge old Netchecker daemonsets + kube: + name: "{{item.item.name}}" + namespace: "{{netcheck_namespace}}" + kubectl: "{{bin_dir}}/kubectl" + resource: "{{item.item.type}}" + filename: "{{kube_config_dir}}/{{item.item.file}}" + state: absent + with_items: "{{ manifests.results }}" + when: inventory_hostname == groups['kube-master'][0] and item.item.type == "ds" and item.changed + - name: Kubernetes Apps | Start Netchecker Resources kube: name: "{{item.item.name}}" diff --git a/roles/kubernetes-apps/efk/fluentd/tasks/main.yml b/roles/kubernetes-apps/efk/fluentd/tasks/main.yml index eebdaed73..728bf156d 100644 --- a/roles/kubernetes-apps/efk/fluentd/tasks/main.yml +++ b/roles/kubernetes-apps/efk/fluentd/tasks/main.yml @@ -1,10 +1,21 @@ --- - name: "Fluentd | Write fluentd daemonset" - template: + template: src: fluentd-ds.yml.j2 dest: "{{ kube_config_dir }}/fluentd-ds.yaml" register: fluentd_ds_manifest +#FIXME: remove if kubernetes/features#124 is implemented +- name: "Fluentd | Purge old fluentd daemonset" + kube: + filename: "{{kube_config_dir}}/fluentd-ds.yaml" + kubectl: "{{bin_dir}}/kubectl" + name: "fluentd-es-v{{ fluentd_version }}" + namespace: "{{system_namespace}}" + resource: "ds" + state: absent + when: inventory_hostname == groups['kube-master'][0] and fluentd_ds_manifest.changed + - name: "Fluentd | Create fluentd daemonset" kube: filename: "{{kube_config_dir}}/fluentd-ds.yaml" diff --git a/roles/kubernetes-apps/network_plugin/canal/tasks/main.yaml b/roles/kubernetes-apps/network_plugin/canal/tasks/main.yaml index 1b8de999a..2133e85fb 100644 --- a/roles/kubernetes-apps/network_plugin/canal/tasks/main.yaml +++ b/roles/kubernetes-apps/network_plugin/canal/tasks/main.yaml @@ -7,6 +7,18 @@ resource: "configmap" namespace: "{{system_namespace}}" +#FIXME: remove if kubernetes/features#124 is implemented +- name: Purge old flannel and canal-node + run_once: true + kube: + name: "canal-node" + kubectl: "{{ bin_dir }}/kubectl" + filename: "{{ kube_config_dir }}/canal-node.yml" + resource: "ds" + namespace: "{{system_namespace}}" + state: absent + when: inventory_hostname == groups['kube-master'][0] and canal_node_manifest.changed + - name: Start flannel and calico-node run_once: true kube: @@ -15,3 +27,6 @@ filename: "{{kube_config_dir}}/canal-node.yaml" resource: "ds" namespace: "{{system_namespace}}" + state: "{{ item | ternary('latest','present') }}" + with_items: "{{ canal_node_manifest.changed }}" + diff --git a/roles/kubernetes-apps/network_plugin/weave/tasks/main.yml b/roles/kubernetes-apps/network_plugin/weave/tasks/main.yml index 9dcfde494..f900e8b09 100644 --- a/roles/kubernetes-apps/network_plugin/weave/tasks/main.yml +++ b/roles/kubernetes-apps/network_plugin/weave/tasks/main.yml @@ -1,3 +1,16 @@ +#FIXME: remove if kubernetes/features#124 is implemented +- name: Weave | Purge old weave daemonset + run_once: true + kube: + name: "weave-net" + kubectl: "{{ bin_dir }}/kubectl" + filename: "{{ kube_config_dir }}/weave-net.yml" + resource: "ds" + namespace: "{{system_namespace}}" + state: absent + when: inventory_hostname == groups['kube-master'][0] and weave_manifest.changed + + - name: Weave | Start Resources run_once: true kube: diff --git a/roles/network_plugin/canal/tasks/main.yml b/roles/network_plugin/canal/tasks/main.yml index 7ccbcdf2e..9402d390c 100644 --- a/roles/network_plugin/canal/tasks/main.yml +++ b/roles/network_plugin/canal/tasks/main.yml @@ -41,6 +41,7 @@ template: src: canal-node.yml.j2 dest: "{{kube_config_dir}}/canal-node.yaml" + register: canal_node_manifest - name: Canal | Copy cni plugins from hyperkube command: "{{ docker_bin_dir }}/docker run --rm -v /opt/cni/bin:/cnibindir {{ hyperkube_image_repo }}:{{ hyperkube_image_tag }} /usr/bin/rsync -a /opt/cni/bin/ /cnibindir/"