Skip to content

Commit

Permalink
Ansible: IPv6 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
samip5 committed Jul 17, 2023
1 parent 6c8b9a4 commit 2cb5732
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ github_username: "{{ bootstrap_github_username }}"
coredns_addr: "{{ bootstrap_coredns_addr }}"
kube_vip_addr: "{{ bootstrap_kube_vip_addr }}"
cluster_cidr: "{{ bootstrap_cluster_cidr }}"
cluster_cidr_v4: "{{ cluster_cidr.split(',')[0] | regex_replace('/.*', '') }}"
cluster_cidr_v6: "{{ cluster_cidr.split(',')[1] | default('') | regex_replace('/.*', '') }}"
service_cidr: "{{ bootstrap_service_cidr }}"
service_cidr_v4: "{{ service_cidr.split(',')[0] | regex_replace('/.*', '') }}"
service_cidr_v6: "{{ service_cidr.split(',')[1] | default('') | regex_replace('/.*', '') }}"
node_cidr: "{{ bootstrap_node_cidr }}"
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

k3s_control_node: true
k3s_server:
{% if ipv6_enabled %}
node-ip: "{% raw %}{{ ansible_host }},{{ ansible_default_ipv6.address }}{% endraw %}"
{% else %}
node-ip: "{% raw %}{{ ansible_host }}{% endraw %}"
{% endif %}
tls-san:
- "{% raw %}{{ kube_vip_addr }}{% endraw %}"
docker: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@

k3s_control_node: false
k3s_agent:
{% if ipv6_enabled %}
node-ip: "{% raw %}{{ ansible_host }},{{ ansible_default_ipv6.address }}{% endraw %}"
{% else %}
node-ip: "{% raw %}{{ ansible_host }}{% endraw %}"
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ spec:
enabled: false
ipam:
mode: kubernetes
{% if ipv6_enabled %}
ipv4NativeRoutingCIDR: "{% raw %}{{ cluster_cidr_v4 }}{% endraw %}"
ipv6NativeRoutingCIDR: "{% raw %}{{ cluster_cidr_v6 }}{% endraw %}"
ipv6:
enabled: true
{% else %}
ipv4NativeRoutingCIDR: "{% raw %}{{ k3s_server['cluster-cidr'] }}{% endraw %}"
{% endif %}
k8sServiceHost: "{% raw %}{{ kube_vip_addr }}{% endraw %}"
k8sServicePort: 6443
kubeProxyReplacement: strict
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
service:
name: kube-dns
# Choose the 10th IP address from the start of the service-cidr
clusterIP: "{% raw %}{{ k3s_server['service-cidr'] | ansible.utils.nthhost(10) }}{% endraw %}"
clusterIP: "{% raw %}{{ service_cidr_v4 | ansible.utils.nthhost(10) }}{% endraw %}"
serviceAccount:
create: true
deployment:
Expand Down
5 changes: 5 additions & 0 deletions bootstrap/vars/config.sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ bootstrap_ingress_nginx_addr:
# Choose your cluster and service cidrs, leave these unchanged unless you know what you are doing
bootstrap_cluster_cidr: 10.42.0.0/16
bootstrap_service_cidr: 10.43.0.0/16
ipv6_enabled: false
# If you want IPv6 enabled, please uncomment the below vars and comment the ones above
# 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
# ipv6_enabled: true

# Node information
bootstrap_nodes:
Expand Down

0 comments on commit 2cb5732

Please sign in to comment.