diff --git a/README.md b/README.md index b931fc4..ea21d35 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,44 @@ roles: control_plane_vip_interface: eth0 ``` +## Example - Deoloy Dualstack Cluster +You can deploy a dual stack cluster with this role. There are some important considerations to make: +- You have to define both, `cluster_cidr` and `service_cidr` with IPv4 and IPv6 address spaces. +- Make sure both address spaces are big enough so that each node can get a `/node_cidr_mask_ipv4` and a `/node_cidr_mask_ipv6` from the `cluster_cidr` address space. (Hence the more complex IPv6 example here) +- A dual stack VIP is currently not supported by the role. + +``` +- name: Setup frist host + host: server-node-1.example.com + + roles: + - role: mtze.rke2 + vars: + first_node_install: true + cluster_cidr: "198.18.0.0/16,fcfe::1:0:0/96" + service_cidr: "198.19.0.0/16,fcfe::1:ffff:0/112" + node_cidr_mask_ipv4: 24 + node_cidr_mask_ipv6: 112 + cni_plugin: calico + control_plane_vip: 10.20.30.1 + control_plane_vip_hostname: control-plane.example.com + control_plane_vip_interface: eth0 + +- name: Setup frist host + host: all_nodes + + roles: + - role: mtze.rke2 + vars: + cluster_cidr: "198.18.0.0/16,fcfe::1:0:0/96" + service_cidr: "198.19.0.0/16,fcfe::1:ffff:0/112" + node_cidr_mask_ipv4: 24 + node_cidr_mask_ipv6: 112 + cni_plugin: calico + control_plane_vip: 10.20.30.1 + control_plane_vip_hostname: control-plane.example.com + control_plane_vip_interface: eth0 +``` # License diff --git a/defaults/main.yml b/defaults/main.yml index 3753f89..c241813 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -44,4 +44,27 @@ fetch_kube_config: true local_kube_config_path: "~/.kube/config-{{ cluster_name }}" +# Cluster domain name (https://docs.rke2.io/install/install_options/server_config/) +cluster_domain: + +# Cluster cidr (Define IP address space used for pods) +# Make sure to configure both IPv4 and IPv6 if you deploy a dualstack cluster) +# example: "198.18.0.0/16,fcfe::43:0:0/96" +cluster_cidr: + +# Service cidr (Define IP address space used for services) +# Make sure to configure both IPv4 and IPv6 if you deploy a dualstack cluster +# example: "198.18.254.0/24,fcfe::43:ffff:0/112" +service_cidr: + +# Define , address of each k8s node explicitly. +node_ips: #FIXME Use Ansible information to fill this automatically + +# Configure the ip range size each cluster node will receive. Make sure that both cidrs are +# smaller then the cluster_cidr! Each node will receive a /{node_cidr_mask_ipv4} and /{node_cidr_mask_ipv4} +# which the node uses to hand out ips to its pods. +node_cidr_mask_ipv4: 24 +node_cidr_mask_ipv6: 112 + + debug_output: false diff --git a/templates/rke2_config.yml.j2 b/templates/rke2_config.yml.j2 index 0a0f135..b43026d 100644 --- a/templates/rke2_config.yml.j2 +++ b/templates/rke2_config.yml.j2 @@ -39,15 +39,26 @@ disable: {# Define the Cluster domain if it is configured as variable #} {% if cluster_domain is not none %} -cluster-domain: {{ cluster_domain }} +cluster-domain: "{{ cluster_domain }}" {% endif %} {# Define the Cluster cidr if it is configured as variable #} {% if cluster_cidr is not none %} -cluster-cidr: {{ cluster_cidr }} +cluster-cidr: "{{ cluster_cidr }}" {% endif %} {# Define the service cidr if it is configured as variable #} {% if service_cidr is not none %} -service-cidr: {{ service_cidr }} +service-cidr: "{{ service_cidr }}" +{% endif %} + +{# Define Node IP adresses explicitly #} +{% if node_ips is not none %} +node-ip: "{{ node_ips }}" +{% endif %} + +{% if node_cidr_mask_ipv4 is not none and node_cidr_mask_ipv6 is not none %} +kube-controller-manager-arg: + - "node-cidr-mask-size-ipv4={{ node_cidr_mask_ipv4 }}" + - "node-cidr-mask-size-ipv6={{ node_cidr_mask_ipv6 }}" {% endif %} diff --git a/vars/main.yml b/vars/main.yml index a36c963..7d4c2ba 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -5,12 +5,3 @@ additional_hostnames: - "{{ inventory_hostname }}" - -# Cluster domain name (https://docs.rke2.io/install/install_options/server_config/) -cluster_domain: - -# Cluster cidr (Define IP address space used for pods) -cluster_cidr: - -# Service cidr (Define IP address space used for services) -service_cidr: