Skip to content

Commit

Permalink
add pdb
Browse files Browse the repository at this point in the history
  • Loading branch information
lobiyedKarim1 committed Nov 29, 2023
1 parent 70bb19d commit 2337a78
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
7 changes: 7 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,15 @@ 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_max_unavailable: 1

# coredns_additional_configs adds any extra configuration to coredns
# coredns_additional_configs: |
# whoami
Expand Down
16 changes: 16 additions & 0 deletions roles/kubernetes-apps/ansible/tasks/coredns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,19 @@
- inventory_hostname == groups['kube_control_plane'][0]
tags:
- coredns

- name: Kubernetes Apps | Lay Down CoreDNS pdb
template:
src: "{{ item.file }}.j2"
dest: "{{ kube_config_dir }}/{{ item.file }}"
mode: 0644
loop:
- { name: coredns, file: coredns-poddisruptionbudget.yml, type: poddisruptionbudget }
register: coredns_optional_manifests
vars:
clusterIP: "{{ skydns_server }}"
when:
- coredns_pod_disruption_budget = true
- inventory_hostname == groups['kube_control_plane'][0]
tags:
- coredns
1 change: 1 addition & 0 deletions roles/kubernetes-apps/ansible/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
with_items:
- "{{ coredns_manifests.results | default({}) }}"
- "{{ coredns_secondary_manifests.results | default({}) }}"
- "{{ coredns_optional_manifests | default({}) }}"
- "{{ nodelocaldns_manifests.results | default({}) }}"
- "{{ nodelocaldns_second_manifests.results | default({}) }}"
when:
Expand Down
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_max_unavailable }}
selector:
matchLabels:
k8s-app: kube-dns{{ coredns_ordinal_suffix }}
{% endif %}

0 comments on commit 2337a78

Please sign in to comment.