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 Jan 11, 2024
1 parent 8c09c3f commit 1540002
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions roles/kubernetes-apps/ansible/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ 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: "30%"

# coredns_additional_configs adds any extra configuration to coredns
# coredns_additional_configs: |
# whoami
Expand Down
4 changes: 4 additions & 0 deletions roles/kubernetes-apps/ansible/tasks/coredns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- { name: dns-autoscaler, file: dns-autoscaler.yml, type: deployment }
- { name: dns-autoscaler, file: dns-autoscaler-clusterrole.yml, type: clusterrole }
- { name: dns-autoscaler, file: dns-autoscaler-clusterrolebinding.yml, type: clusterrolebinding }
- { name: coredns, file: coredns-poddisruptionbudget.yml, type: poddisruptionbudget, when: "{{ coredns_pod_disruption_budget }}"}
- { name: dns-autoscaler, file: dns-autoscaler-sa.yml, type: sa }
register: coredns_manifests
vars:
Expand All @@ -22,6 +23,7 @@
- dns_mode in ['coredns', 'coredns_dual']
- inventory_hostname == groups['kube_control_plane'][0]
- enable_dns_autoscaler or item.name != 'dns-autoscaler'
- item.when | default(True) | bool
tags:
- coredns

Expand All @@ -34,6 +36,7 @@
- { 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 }}"
Expand All @@ -42,5 +45,6 @@
- dns_mode == 'coredns_dual'
- inventory_hostname == groups['kube_control_plane'][0]
- enable_dns_autoscaler or item.name != 'dns-autoscaler'
- item.when | default(True) | bool
tags:
- coredns
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
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 }}

0 comments on commit 1540002

Please sign in to comment.