From 2fee9a174751d065f11ae39fe2def37d2a76eb1a Mon Sep 17 00:00:00 2001 From: Ruakij Date: Sun, 19 Mar 2023 14:00:15 +0100 Subject: [PATCH] Only enable ipv6 when available and activated --- kubernetes/templates/k3s/agent/config.yaml.jinja2 | 6 +++++- kubernetes/templates/k3s/server/config.yaml.jinja2 | 11 ++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/kubernetes/templates/k3s/agent/config.yaml.jinja2 b/kubernetes/templates/k3s/agent/config.yaml.jinja2 index 417f719..0507054 100644 --- a/kubernetes/templates/k3s/agent/config.yaml.jinja2 +++ b/kubernetes/templates/k3s/agent/config.yaml.jinja2 @@ -1,7 +1,11 @@ server: https://{{ kubernetes.control_plane.dns_name }}:6443 token: {{ kubernetes.token }} -node-ip: {{ nodeip_ipv4 }},{{ nodeip_ipv6 }} +{% if nodeip_ipv6 != "" and kubernetes.ipPool.ipv6 is defined %} +node-ip: {{ nodeip_ipv4 }},{{ nodeip_ipv6 }} # FIXME: Workaround for bug in Kubernetes 1.24/1.25 ignoring node IPv6 addresses kubelet-arg: "--node-ip=0.0.0.0" +{% else %} +node-ip: {{ nodeip_ipv4 }} +{% endif %} diff --git a/kubernetes/templates/k3s/server/config.yaml.jinja2 b/kubernetes/templates/k3s/server/config.yaml.jinja2 index f348279..e57e4a4 100644 --- a/kubernetes/templates/k3s/server/config.yaml.jinja2 +++ b/kubernetes/templates/k3s/server/config.yaml.jinja2 @@ -11,9 +11,18 @@ tls-san: - {{ kubernetes.control_plane.dns_name }} # Networking +{% if nodeip_ipv6 != "" and kubernetes.ipPool.ipv6 is defined %} node-ip: {{ nodeip_ipv4 }},{{ nodeip_ipv6 }} cluster-cidr: {{ kubernetes.ipPool.ipv4.cluster_cidr }},{{ kubernetes.ipPool.ipv6.cluster_cidr }} -service-cidr: {{ kubernetes.ipPool.ipv4.service_cidr }},{{ kubernetes.ipPool.ipv6.service_cidr }} +service-cidr: {{ kubernetes.ipPool.ipv4.service_cidr }},{{ kubernetes.ipPool.ipv6.service_cidr }} + +# FIXME: Workaround for bug in Kubernetes 1.24/1.25 ignoring node IPv6 addresses +kubelet-arg: "--node-ip=0.0.0.0" +{% else %} +node-ip: {{ nodeip_ipv4 }} +cluster-cidr: {{ kubernetes.ipPool.ipv4.cluster_cidr }} +service-cidr: {{ kubernetes.ipPool.ipv4.service_cidr }} +{% endif %} egress-selector-mode: disabled