From 3d385fa8acbd4145f8152a3b0793aaf2167a22c7 Mon Sep 17 00:00:00 2001 From: bom Date: Thu, 21 Jul 2022 16:08:13 +0200 Subject: [PATCH] Use node_ipv4 in traefik As we are now using NodePools with more than one IP this ensures that the traefik and subsequently ingresses always have the IP-Address associated with the DNS entry and not a randomly selected one. --- .../provs/server/infrastructure/K3s.kt | 5 ++--- .../k3s/{traefik.yaml => traefik.template.yaml} | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) rename src/main/resources/org/domaindrivenarchitecture/provs/server/infrastructure/k3s/{traefik.yaml => traefik.template.yaml} (97%) diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/K3s.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/K3s.kt index bb0c6cd..6b53ff0 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/K3s.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/K3s.kt @@ -29,7 +29,7 @@ private val k3sInstallScript = File( "/usr/local/bin/k3s-install.sh") private val k3sConfigFile = File( "/etc/rancher/k3s/config.yaml") private val k3sKubeConfig = File("/etc/rancher/k3s/k3s.yaml") -private val k3sTraefikWorkaround = File(k3sManualManifestsDir, "traefik.yaml") +private val k3sTraefikWorkaround = File(k3sManualManifestsDir, "traefik.template.yaml") private val certManagerDeployment = File(k3sManualManifestsDir, "cert-manager.yaml") private val certManagerIssuer = File(k3sManualManifestsDir, "le-issuer.yaml") @@ -100,8 +100,7 @@ fun Prov.installK3s(k3sConfig: K3sConfig): ProvResult { // traefik if (k3sConfig.isDualStack()) { // see https://github.com/k3s-io/k3s/discussions/5003 - createK3sFileFromResource(k3sTraefikWorkaround) - applyK3sFile(k3sTraefikWorkaround) + applyK3sFileFromResourceTemplate(k3sTraefikWorkaround, k3sConfigMap) } else { ProvResult(true) } diff --git a/src/main/resources/org/domaindrivenarchitecture/provs/server/infrastructure/k3s/traefik.yaml b/src/main/resources/org/domaindrivenarchitecture/provs/server/infrastructure/k3s/traefik.template.yaml similarity index 97% rename from src/main/resources/org/domaindrivenarchitecture/provs/server/infrastructure/k3s/traefik.yaml rename to src/main/resources/org/domaindrivenarchitecture/provs/server/infrastructure/k3s/traefik.template.yaml index 6d1ddef..c1f4b30 100644 --- a/src/main/resources/org/domaindrivenarchitecture/provs/server/infrastructure/k3s/traefik.yaml +++ b/src/main/resources/org/domaindrivenarchitecture/provs/server/infrastructure/k3s/traefik.template.yaml @@ -46,6 +46,7 @@ spec: effect: "NoSchedule" service: ipFamilyPolicy: "PreferDualStack" + loadBalancerIP: ${node_ipv4} spec: type: LoadBalancer externalTrafficPolicy: Local