fix: kube-dns service deletion (#8565)

Signed-off-by: Cyril Corbon <corboncyril@gmail.com>
This commit is contained in:
cyril-corbon 2022-02-21 11:48:11 +01:00 committed by GitHub
parent 2537177929
commit 418fc00718
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View file

@ -1,7 +1,16 @@
--- ---
- name: Kubernetes Apps | Register coredns deployment annotation `createdby` - name: Kubernetes Apps | Register coredns deployment annotation `createdby`
command: "{{ kubectl }} get deploy -n kube-system coredns -o jsonpath='{ .spec.template.metadata.annotations.createdby }'" command: "{{ kubectl }} get deploy -n kube-system coredns -o jsonpath='{ .spec.template.metadata.annotations.createdby }'"
register: createdby_annotation register: createdby_annotation_deploy
changed_when: false
ignore_errors: true # noqa ignore-errors
when:
- dns_mode in ['coredns', 'coredns_dual']
- inventory_hostname == groups['kube_control_plane'][0]
- name: Kubernetes Apps | Register coredns service annotation `createdby`
command: "{{ kubectl }} get svc -n kube-system kube-dns -o jsonpath='{ .metadata.annotations.createdby }'"
register: createdby_annotation_svc
changed_when: false changed_when: false
ignore_errors: true # noqa ignore-errors ignore_errors: true # noqa ignore-errors
when: when:
@ -18,7 +27,7 @@
when: when:
- dns_mode in ['coredns', 'coredns_dual'] - dns_mode in ['coredns', 'coredns_dual']
- inventory_hostname == groups['kube_control_plane'][0] - inventory_hostname == groups['kube_control_plane'][0]
- createdby_annotation.stdout != 'kubespray' - createdby_annotation_deploy.stdout != 'kubespray'
- name: Kubernetes Apps | Delete kubeadm Kube-DNS service - name: Kubernetes Apps | Delete kubeadm Kube-DNS service
kube: kube:
@ -30,3 +39,4 @@
when: when:
- dns_mode in ['coredns', 'coredns_dual'] - dns_mode in ['coredns', 'coredns_dual']
- inventory_hostname == groups['kube_control_plane'][0] - inventory_hostname == groups['kube_control_plane'][0]
- createdby_annotation_svc.stdout != 'kubespray'

View file

@ -11,6 +11,7 @@ metadata:
annotations: annotations:
prometheus.io/port: "9153" prometheus.io/port: "9153"
prometheus.io/scrape: "true" prometheus.io/scrape: "true"
createdby: 'kubespray'
spec: spec:
selector: selector:
k8s-app: kube-dns{{ coredns_ordinal_suffix }} k8s-app: kube-dns{{ coredns_ordinal_suffix }}