Skip to content

Commit

Permalink
feat(cni): add preflight role support for custom_cni
Browse files Browse the repository at this point in the history
  • Loading branch information
HoKim98 committed Aug 8, 2024
1 parent 7ad503e commit d3d38c8
Show file tree
Hide file tree
Showing 18 changed files with 67 additions and 58 deletions.
54 changes: 0 additions & 54 deletions roles/kubernetes-apps/ansible/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,4 @@
---
# Limits for coredns

# uncomment the line below to customize the DNS cpu limit value
# dns_cpu_limit: 300m
dns_memory_limit: 300Mi
dns_cpu_requests: 100m
dns_memory_requests: 70Mi
dns_min_replicas: "{{ [2, groups['k8s_cluster'] | length] | min }}"
dns_nodes_per_replica: 16
dns_cores_per_replica: 256
dns_prevent_single_point_failure: "{{ 'true' if dns_min_replicas | int > 1 else 'false' }}"
enable_coredns_reverse_dns_lookups: true
coredns_ordinal_suffix: ""
# dns_extra_tolerations: [{effect: NoSchedule, operator: "Exists"}]
coredns_deployment_nodeselector: "kubernetes.io/os: linux"
coredns_default_zone_cache_block: |
cache 30
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
# local

# coredns_rewrite_block: |
# rewrite stop {
# name regex (.*)\.my\.domain {1}.svc.cluster.local
# answer name (.*)\.svc\.cluster\.local {1}.my.domain
# }

# coredns_additional_error_config: |
# consolidate 5m ".* i/o timeout$" warning

# Configure coredns and nodelocaldns to correctly answer DNS queries when you changed
# your 'dns_domain' and some workloads used it directly.
old_dns_domains: []

# dns_upstream_forward_extra_opts apply to coredns forward section as well as nodelocaldns upstream target forward section
# dns_upstream_forward_extra_opts:
# policy: sequential

# Apply extra options to coredns kubernetes plugin
# coredns_kubernetes_extra_opts:
# - 'fallthrough example.local'

# nodelocaldns
nodelocaldns_cpu_requests: 100m
nodelocaldns_memory_limit: 200Mi
Expand All @@ -55,12 +7,6 @@ nodelocaldns_ds_nodeselector: "kubernetes.io/os: linux"
nodelocaldns_prometheus_port: 9253
nodelocaldns_secondary_prometheus_port: 9255

# Limits for dns-autoscaler
dns_autoscaler_cpu_requests: 20m
dns_autoscaler_memory_requests: 10Mi
dns_autoscaler_deployment_nodeselector: "kubernetes.io/os: linux"
# dns_autoscaler_extra_tolerations: [{effect: NoSchedule, operator: "Exists"}]

# etcd metrics
# etcd_metrics_service_labels:
# k8s-app: etcd
Expand Down
3 changes: 2 additions & 1 deletion roles/kubernetes-apps/ansible/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
when: inventory_hostname == groups['kube_control_plane'][0]

- name: Kubernetes Apps | CoreDNS
import_tasks: "coredns.yml"
include_role:
name: kubernetes-apps/coredns
when:
- dns_mode in ['coredns', 'coredns_dual']
- inventory_hostname == groups['kube_control_plane'][0]
Expand Down
54 changes: 54 additions & 0 deletions roles/kubernetes-apps/coredns/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
# Limits for coredns

# uncomment the line below to customize the DNS cpu limit value
# dns_cpu_limit: 300m
dns_memory_limit: 300Mi
dns_cpu_requests: 100m
dns_memory_requests: 70Mi
dns_min_replicas: "{{ [2, groups['k8s_cluster'] | length] | min }}"
dns_nodes_per_replica: 16
dns_cores_per_replica: 256
dns_prevent_single_point_failure: "{{ 'true' if dns_min_replicas | int > 1 else 'false' }}"
enable_coredns_reverse_dns_lookups: true
coredns_ordinal_suffix: ""
# dns_extra_tolerations: [{effect: NoSchedule, operator: "Exists"}]
coredns_deployment_nodeselector: "kubernetes.io/os: linux"
coredns_default_zone_cache_block: |
cache 30
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
# local

# coredns_rewrite_block: |
# rewrite stop {
# name regex (.*)\.my\.domain {1}.svc.cluster.local
# answer name (.*)\.svc\.cluster\.local {1}.my.domain
# }

# coredns_additional_error_config: |
# consolidate 5m ".* i/o timeout$" warning

# Configure coredns and nodelocaldns to correctly answer DNS queries when you changed
# your 'dns_domain' and some workloads used it directly.
old_dns_domains: []

# dns_upstream_forward_extra_opts apply to coredns forward section as well as nodelocaldns upstream target forward section
# dns_upstream_forward_extra_opts:
# policy: sequential

# Apply extra options to coredns kubernetes plugin
# coredns_kubernetes_extra_opts:
# - 'fallthrough example.local'

# Limits for dns-autoscaler
dns_autoscaler_cpu_requests: 20m
dns_autoscaler_memory_requests: 10Mi
dns_autoscaler_deployment_nodeselector: "kubernetes.io/os: linux"
# dns_autoscaler_extra_tolerations: [{effect: NoSchedule, operator: "Exists"}]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Kubernetes Apps | Lay Down CoreDNS templates
- name: CoreDNS | Lay Down CoreDNS templates
template:
src: "{{ item.file }}.j2"
dest: "{{ kube_config_dir }}/{{ item.file }}"
Expand Down Expand Up @@ -27,7 +27,7 @@
tags:
- coredns

- name: Kubernetes Apps | Lay Down Secondary CoreDNS Template
- name: CoreDNS | Lay Down Secondary CoreDNS Template
template:
src: "{{ item.src }}.j2"
dest: "{{ kube_config_dir }}/{{ item.file }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@
loop: "{{ custom_cni_preflight_templates }}"
delegate_to: "{{ groups['kube_control_plane'] | first }}"
run_once: true

- name: Custom CNI | Preflight | Start Roles
include_role:
name: "{{ custom_cni_preflight_role }}"
loop: "{{ custom_cni_preflight_roles }}"
loop_control:
loop_var: custom_cni_preflight_role
run_once: true
1 change: 1 addition & 0 deletions roles/network_plugin/custom_cni/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---

custom_cni_preflight_roles: []
custom_cni_preflight_templates: []

custom_cni_manifests: []
Expand Down
1 change: 0 additions & 1 deletion roles/network_plugin/custom_cni/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ dependencies:
when:
- inventory_hostname == groups['kube_control_plane'][0]
- custom_cni_chart_release_name | length > 0
- custom_cni_preflight_templates | length > 0
environment:
http_proxy: "{{ http_proxy | default('') }}"
https_proxy: "{{ https_proxy | default('') }}"
Expand Down

0 comments on commit d3d38c8

Please sign in to comment.