Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add custom dns server support #1199

Merged
merged 2 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/tests/config-k0s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ bootstrap_kube_api_hostname: fake
bootstrap_k8s_gateway_addr: 10.10.10.253
bootstrap_external_ingress_addr: 10.10.10.252
bootstrap_internal_ingress_addr: 10.10.10.251
bootstrap_dns_server: 1.1.1.1
bootstrap_cilium_loadbalancer_mode: dsr
bootstrap_ipv6_enabled: false
bootstrap_cluster_cidr: 10.42.0.0/16
Expand Down
1 change: 1 addition & 0 deletions .github/tests/config-k3s-ipv4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ bootstrap_kube_api_hostname: fake
bootstrap_k8s_gateway_addr: 10.10.10.253
bootstrap_external_ingress_addr: 10.10.10.252
bootstrap_internal_ingress_addr: 10.10.10.251
bootstrap_dns_server: 1.1.1.1
bootstrap_cilium_loadbalancer_mode: dsr
bootstrap_ipv6_enabled: false
bootstrap_cluster_cidr: 10.42.0.0/16
Expand Down
1 change: 1 addition & 0 deletions .github/tests/config-k3s-ipv6.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ bootstrap_k8s_gateway_addr: 10.10.10.253
bootstrap_external_ingress_addr: 10.10.10.252
bootstrap_internal_ingress_addr: 10.10.10.251
bootstrap_cilium_loadbalancer_mode: dsr
bootstrap_dns_server: 1.1.1.1
bootstrap_ipv6_enabled: true
bootstrap_cluster_cidr: 10.42.0.0/16,fd7f:8f5:e87c:a::/64
bootstrap_service_cidr: 10.43.0.0/16,fd7f:8f5:e87c:e::/112
Expand Down
1 change: 1 addition & 0 deletions .github/tests/config-k3s-no-kube-vip.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ bootstrap_kube_api_hostname: fake
bootstrap_k8s_gateway_addr: 10.10.10.253
bootstrap_external_ingress_addr: 10.10.10.252
bootstrap_internal_ingress_addr: 10.10.10.251
bootstrap_dns_server: 1.1.1.1
bootstrap_cilium_loadbalancer_mode: dsr
bootstrap_ipv6_enabled: false
bootstrap_cluster_cidr: 10.42.0.0/16
Expand Down
1 change: 1 addition & 0 deletions .github/tests/config-talos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ bootstrap_k8s_gateway_addr: 10.10.10.253
bootstrap_external_ingress_addr: 10.10.10.252
bootstrap_internal_ingress_addr: 10.10.10.251
bootstrap_cilium_loadbalancer_mode: dsr
bootstrap_dns_server: 1.1.1.1
bootstrap_ipv6_enabled: false
bootstrap_cluster_cidr: 10.42.0.0/16
bootstrap_service_cidr: 10.43.0.0/16
Expand Down
6 changes: 6 additions & 0 deletions bootstrap/tasks/validation/net.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@
success_msg: Kube API address {{ bootstrap_kube_api_addr }} is within {{ bootstrap_node_cidr }}.
fail_msg: Kube API address {{ bootstrap_kube_api_addr }} is not within {{ bootstrap_node_cidr }}.

- name: Check if DNS server is ipv4
ansible.builtin.assert:
that: bootstrap_dns_server is ansible.utils.ipv4
success_msg: DNS server {{ bootstrap_dns_server }} is valid.
fail_msg: DNS server {{ bootstrap_dns_server }} is invalid.

- name: Check if all IP addresses are unique
ansible.builtin.assert:
that: >
Expand Down
1 change: 1 addition & 0 deletions bootstrap/tasks/validation/vars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- bootstrap_cloudflare_tunnel_secret
- bootstrap_cluster_cidr
- bootstrap_distribution
- bootstrap_dns_server
- bootstrap_external_ingress_addr
- bootstrap_flux_github_webhook_token
- bootstrap_github_repository_branch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
dest: /etc/resolv.conf
content: |
search .
nameserver 1.1.1.1
nameserver #{ bootstrap_dns_server | default('1.1.1.1', true) }#

- name: System Configuration
notify: Reboot
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/templates/kubernetes/talos/talconfig.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ controlPlane:
machine:
network:
nameservers:
- 1.1.1.1
- "#{ bootstrap_dns_server | default('1.1.1.1', true) }#"

# Configure NTP
- &ntpPatch |-
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/vars/addons.sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ system_upgrade_controller:
# WARNING: Only enable this if you also track the version of k3s in the
# ansible configuration files. Running ansible against an already provisioned
# cluster with this enabled might cause your cluster to be downgraded.
# Note: If bootstrap_distribution is set to k0s this will be ignored.
# Note: If bootstrap_distribution is set to k0s or talos this will be ignored.
enabled: false

# https://github.com/morphy2k/rss-forwarder
Expand Down
7 changes: 7 additions & 0 deletions bootstrap/vars/config.sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ bootstrap_external_ingress_addr:
# The Load balancer IP for internal ingress, choose an available IP in your nodes network that is not being used
bootstrap_internal_ingress_addr:

# The DNS server to use for the cluster, this can be an existing local DNS server or a public one
# If using a local DNS server make sure it meets the following requirements:
# 1. your nodes can reach it
# 2. it is configured to forward requests to a public DNS server
# 3. you are not force redirecting DNS requests to it - this will break cert generation over DNS01
bootstrap_dns_server: 1.1.1.1

# (Advanced) Cilium load balancer mode, choose either 'dsr' or 'snat'
# Due to unknown reasons some people need this set to 'snat' in order
# for Cilium L2 announcements to work properly. Keep this dsr unless
Expand Down