Skip to content

Commit

Permalink
ipv6 in testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
borislitv committed Jan 24, 2025
1 parent 76d5b08 commit 3dc5142
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
8 changes: 6 additions & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,16 @@ Vagrant.configure("2") do |config|
:libvirt__forward_mode => "none",
:libvirt__dhcp_enabled => false

# libvirt__ipv6_address does not work as intended, the address is obtained with the desired prefix, but auto-generated(like fd3c:b398:698:756:5054:ff:fe48:c61e/64)
# add default route for detect ansible_default_ipv6
# TODO: fix libvirt__ipv6 or use $subnet in shell
config.vm.provision "shell", inline: "ip -6 r add default via fd3c:b398:0698:0756::1 dev eth1 || true"

# Disable swap for each vm
node.vm.provision "shell", inline: "swapoff -a"

# ubuntu2004 and ubuntu2204 have IPv6 explicitly disabled. This undoes that.
if ["ubuntu2004", "ubuntu2204", "ubuntu2404"].include? $os
if ["ubuntu2004", "ubuntu2204"].include? $os
node.vm.provision "shell", inline: "rm -f /etc/modprobe.d/local.conf"
node.vm.provision "shell", inline: "sed -i '/net.ipv6.conf.all.disable_ipv6/d' /etc/sysctl.d/99-sysctl.conf /etc/sysctl.conf"
end
Expand Down Expand Up @@ -251,7 +256,6 @@ Vagrant.configure("2") do |config|

host_vars[vm_name] = {
"ip": ip,
"ip6": ip6,
"flannel_interface": "eth1",
"kube_network_plugin": $network_plugin,
"kube_network_plugin_multus": $multi_networking,
Expand Down
3 changes: 3 additions & 0 deletions docs/ansible/vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ Some variables of note include:
* *access_ip* - IP to use from other hosts to connect to this host. Often required when deploying
from a cloud, such as OpenStack or GCE and you have separate public/floating and private IPs.
This would **usually** be the private ip.
* *access_ip6* - IPv6 to use from other hosts to connect to this host.
* *ansible_default_ipv4.address* - Not Kubespray-specific, but it is used if ip
and access_ip are undefined
* *ansible_default_ipv6.address* - Not Kubespray-specific, but it is used if ip
and access_ip6 are undefined
* *ip6* - IPv6 address to use for binding services. (host var)
If *enable_dual_stack_networks* is set to ``true`` and *ip6* is defined,
kubelet's ``--node-ip`` and node's ``InternalIP`` will be the combination of *ip* and *ip6*.
Expand Down
2 changes: 1 addition & 1 deletion roles/kubernetes/client/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
user_certs: "{{ admin_kubeconfig['users'][0]['user'] }}"
username: "kubernetes-admin-{{ cluster_name }}"
context: "kubernetes-admin-{{ cluster_name }}@{{ cluster_name }}"
override_cluster_name: "{{ {'clusters': [{'cluster': (cluster_infos | combine({'server': 'https://' + external_apiserver_address + ':' + (external_apiserver_port | string)})), 'name': cluster_name}]} }}"
override_cluster_name: "{{ {'clusters': [{'cluster': (cluster_infos | combine({'server': 'https://' + (external_apiserver_address | ansible.utils.ipwrap) + ':' + (external_apiserver_port | string)})), 'name': cluster_name}]} }}"
override_context: "{{ {'contexts': [{'context': {'user': username, 'cluster': cluster_name}, 'name': context}], 'current-context': context} }}"
override_user: "{{ {'users': [{'name': username, 'user': user_certs}]} }}"
when: kubeconfig_localhost
Expand Down
2 changes: 1 addition & 1 deletion roles/kubespray-defaults/defaults/main/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ ssl_ca_dirs: |-
# Vars for pointing to kubernetes api endpoints
kube_apiserver_count: "{{ groups['kube_control_plane'] | length }}"
kube_apiserver_address: "{{ lookup('ansible.builtin.vars', 'ip' + default_net_mode, default=hostvars[inventory_hostname]['fallback_ip' + default_net_mode]) }}"
kube_apiserver_access_address: "{{ access_ip | default(kube_apiserver_address) }}"
kube_apiserver_access_address: "{{ lookup('ansible.builtin.vars', 'access_ip' + default_net_mode, default=kube_apiserver_address) }}"
first_kube_control_plane_address: "{{ hostvars[groups['kube_control_plane'][0]]['access_ip' + default_net_mode] | default(hostvars[groups['kube_control_plane'][0]]['ip' + default_net_mode] | default(hostvars[groups['kube_control_plane'][0]]['fallback_ip' + default_net_mode])) | ansible.utils.ipwrap }}"
loadbalancer_apiserver_localhost: "{{ loadbalancer_apiserver is not defined }}"
loadbalancer_apiserver_type: "nginx"
Expand Down
3 changes: 3 additions & 0 deletions tests/files/vagrant_ubuntu24-calico-ipv6only-stack.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
$os = "ubuntu2404"

$vm_cpus = 2
$libvirt_volume_cache = "unsafe"

# Checking for box update can trigger API rate limiting
# https://www.vagrantup.com/docs/vagrant-cloud/request-limits.html
$box_check_update = false
Expand Down

0 comments on commit 3dc5142

Please sign in to comment.