Skip to content

Commit

Permalink
Merge pull request #1 from Mtze/make-dual-stack-configurable
Browse files Browse the repository at this point in the history
Make dual stack configurable
  • Loading branch information
Mtze authored Feb 7, 2022
2 parents 934f3ae + 04d87ef commit 3b4fc72
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 12 deletions.
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
23 changes: 23 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <IPv4>,<IPv6> 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
17 changes: 14 additions & 3 deletions templates/rke2_config.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
9 changes: 0 additions & 9 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:

0 comments on commit 3b4fc72

Please sign in to comment.