diff --git a/shared/kubernetes/k3s.go b/shared/kubernetes/k3s.go index 38618e95c..53109e670 100644 --- a/shared/kubernetes/k3s.go +++ b/shared/kubernetes/k3s.go @@ -33,6 +33,10 @@ func InstallK3sTraefikConfig(tcpPorts []types.PortMap, udpPorts []types.PortMap) } // Wait for traefik to be back + waitForTraefik() +} + +func waitForTraefik() { log.Info().Msg(L("Waiting for Traefik to be reloaded")) for i := 0; i < 60; i++ { out, err := utils.RunCmdOutput(zerolog.TraceLevel, "kubectl", "get", "job", "-n", "kube-system", @@ -50,6 +54,21 @@ func InstallK3sTraefikConfig(tcpPorts []types.PortMap, udpPorts []types.PortMap) // UninstallK3sTraefikConfig uninstall K3s Traefik configuration. func UninstallK3sTraefikConfig(dryRun bool) { + // Write a blank file first to get traefik to be reinstalled + if !dryRun { + log.Info().Msg(L("Reinstalling Traefik without additionnal configuration")) + err := os.WriteFile(k3sTraefikConfigPath, []byte{}, 0600) + if err != nil { + log.Error().Err(err).Msg(L("failed to write empty traefik configuration")) + } else { + // Wait for traefik to be back + waitForTraefik() + } + } else { + log.Info().Msg(L("Would reinstall Traefik without additionnal configuration")) + } + + // Now that it's reinstalled, remove the file utils.UninstallFile(k3sTraefikConfigPath, dryRun) }