Skip to content

Commit

Permalink
Tolerate failed coredns svc errors on kubeadm init/upgrade
Browse files Browse the repository at this point in the history
Also deletes kube-dns svc in kube-system namespace which is unused

Change-Id: I61798a258efbc3f6ee72cd57f68a776db063d417
  • Loading branch information
mattymo committed Nov 4, 2020
1 parent fc22453 commit 8f0daa9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
4 changes: 4 additions & 0 deletions roles/kubernetes/master/tasks/kubeadm-secondary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
register: kubeadm_join_control_plane
retries: 3
until: kubeadm_join_control_plane is succeeded
failed_when:
- kubeadm_join_control_plane.rc != 0
- '"field is immutable" not in kubeadm_join_control_plane.stderr'
- '"unable to create/update the DNS service" not in kubeadm_join_control_plane.stdaerr'
when:
- inventory_hostname != groups['kube-master']|first
- kubeadm_already_run is not defined or not kubeadm_already_run.stat.exists
Expand Down
23 changes: 22 additions & 1 deletion roles/kubernetes/master/tasks/kubeadm-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
retries: 3
until: kubeadm_upgrade.rc == 0
when: inventory_hostname == groups['kube-master']|first
failed_when: kubeadm_upgrade.rc != 0 and "field is immutable" not in kubeadm_upgrade.stderr
failed_when:
- kubeadm_upgrade.rc != 0
- '"field is immutable" not in kubeadm_upgrade.stderr'
- '"unable to create/update the DNS service" not in kubeadm_upgrade.stderr'
environment:
PATH: "{{ bin_dir }}:{{ ansible_env.PATH }}"
notify: Master | restart kubelet
Expand All @@ -44,6 +47,8 @@
failed_when:
- kubeadm_upgrade.rc != 0
- '"field is immutable" not in kubeadm_upgrade.stderr'
- '"unable to create/update the DNS service" not in kubeadm_upgrade.stderr'
- kubeadm_upgrade.stdout_lines | length > 1
environment:
PATH: "{{ bin_dir }}:{{ ansible_env.PATH }}"
notify: Master | restart kubelet
Expand Down Expand Up @@ -72,3 +77,19 @@
- kubeadm_scale_down_coredns_enabled
- dns_mode not in ['coredns', 'coredns_dual']
changed_when: false

- name: kubeadm | Remove kube-dns service if kubeadm upgrade created it
command: >-
{{ bin_dir }}/kubectl
--kubeconfig /etc/kubernetes/admin.conf
-n kube-system
delete svc kube-dns
register: delete_svc_kube_dns
retries: 6
delay: 2
until: delete_svc_kube_dns is succeeded
run_once: yes
when:
- dns_mode not in ['coredns', 'coredns_dual']
failed_when: false
changed_when: false

0 comments on commit 8f0daa9

Please sign in to comment.