Skip to content

Commit

Permalink
Add PodDisruptionBudget for CoreDNS deployment. Allows users to contr…
Browse files Browse the repository at this point in the history
…ol disruption behavior and set maximum unavailable pods
  • Loading branch information
lobiyedKarim1 committed Dec 8, 2023
1 parent 0d7bdc6 commit 5656a52
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions roles/kubernetes-apps/ansible/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ coredns_ordinal_suffix: ""
coredns_deployment_nodeselector: "kubernetes.io/os: linux"
coredns_default_zone_cache_block: |
cache 30
coredns_host_network: false
coredns_port: 53

coredns_pod_disruption_budget: false
# value for coredns pdb
coredns_pod_disruption_budget_max_unavailable: 1

# coredns_additional_configs adds any extra configuration to coredns
# coredns_additional_configs: |
# whoami
Expand Down
2 changes: 2 additions & 0 deletions roles/kubernetes-apps/ansible/tasks/coredns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@
- { name: coredns, src: coredns-deployment.yml, file: coredns-deployment-secondary.yml, type: deployment }
- { name: coredns, src: coredns-svc.yml, file: coredns-svc-secondary.yml, type: svc }
- { name: dns-autoscaler, src: dns-autoscaler.yml, file: coredns-autoscaler-secondary.yml, type: deployment }
- { name: coredns, file: coredns-poddisruptionbudget.yml, type: poddisruptionbudget, when: "{{ coredns_pod_disruption_budget }}"}
register: coredns_secondary_manifests
vars:
clusterIP: "{{ skydns_server_secondary }}"
coredns_ordinal_suffix: "-secondary"
when:
- dns_mode == 'coredns_dual'
- inventory_hostname == groups['kube_control_plane'][0]
- item.when | default(True) | bool
tags:
- coredns
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{%- if coredns_pod_disruption_budget -%}
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: coredns{{ coredns_ordinal_suffix }}
spec:
maxUnavailable: {{ coredns_pod_disruption_budget_max_unavailable }}
selector:
matchLabels:
k8s-app: kube-dns{{ coredns_ordinal_suffix }}
{% endif %}

0 comments on commit 5656a52

Please sign in to comment.