lablabs / ansible-role-rke2

Ansible Role to install RKE2 Kubernetes.
https://galaxy.ansible.com/ui/standalone/roles/lablabs/rke2/
MIT License
290 stars 145 forks source link

feature: Enable dual stack network #122

Open VanDuy91 opened 1 year ago

VanDuy91 commented 1 year ago

Summary

Hello, How can I enable dual stack network when init k8s cluster (with input IP/IPv6 addresses from main.yaml)

Thank you.

Issue Type

Feature Idea

JcGKitten commented 1 year ago

Isn't this possible by adding

rke2_server_options:
    - "cluster-cidr: '10.42.0.0/16,2001:cafe:42:0::/56'"
    - "service-cidr: '10.43.0.0/16,2001:cafe:42:1::/112'"

to the hosts where your control nodes are run?

tregad commented 1 month ago

Should be possible by adding something like this:

diff --git a/defaults/main.yml b/defaults/main.yml
index 562d960..bd17171 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -294,3 +294,9 @@ rke2_debug: false

 # The value for the node-name configuration item
 rke2_node_name: "{{ inventory_hostname }}"
+# default pod network range for rke2
+rke2_cluster_cidr:
+  - 10.42.0.0/16
+# default service network range for rke2
+rke2_service_cidr:
+  - 10.43.0.0/16
diff --git a/templates/config.yaml.j2 b/templates/config.yaml.j2
index 5bf78d0..9317e5d 100644
--- a/templates/config.yaml.j2
+++ b/templates/config.yaml.j2
@@ -90,3 +90,9 @@ kube-proxy-arg:
 disable-cloud-controller: true
 cloud-provider-name: "{{ rke2_cloud_provider_name }}"
 {% endif %}
+{% if rke2_cluster_cidr is defined %}
+cluster-cidr: "{% for network in rke2_cluster_cidr %}{{ network }}{% if not loop['last'] %},{% endif %}{% endfor %}"
+{% endif %}
+{% if rke2_service_cidr is defined %}
+service-cidr: "{% for network in rke2_service_cidr %}{{ network }}{% if not loop['last'] %},{% endif %}{% endfor %}"
+{% endif %}