From 85c0bcfac0cc426159c7b962f8f00b828e5a8482 Mon Sep 17 00:00:00 2001 From: yafeng-Soong <397655952@qq.com> Date: Sun, 4 Oct 2026 19:51:53 +0800 Subject: [PATCH] fix(k8s): link kubeadm config to /kind/kubeadm.conf for cert regeneration Signed-off-by: yafeng-Soong <397655952@qq.com> --- Sources/ContainerK8s/Support/K8sHelper+Bootstrap.swift | 8 ++++++++ Tests/IntegrationTests/K8s/TestK8sRunSerial.swift | 3 +++ 2 files changed, 11 insertions(+) diff --git a/Sources/ContainerK8s/Support/K8sHelper+Bootstrap.swift b/Sources/ContainerK8s/Support/K8sHelper+Bootstrap.swift index 720794515..0ee5e0def 100644 --- a/Sources/ContainerK8s/Support/K8sHelper+Bootstrap.swift +++ b/Sources/ContainerK8s/Support/K8sHelper+Bootstrap.swift @@ -46,6 +46,14 @@ extension K8sHelper { throw ContainerizationError(.internalError, message: "write kubeadm config failed on \(nodeID): \(r.output)") } + r = try await execCapture( + containerId: nodeID, executable: "/bin/sh", + arguments: ["-c", "mkdir -p /kind && ln -sf /etc/kubernetes/kubeadm-config.yaml /kind/kubeadm.conf"], + client: client) + guard r.code == 0 else { + throw ContainerizationError(.internalError, message: "failed to link kind kubeadm config on \(nodeID): \(r.output)") + } + log.info("Running kubeadm init", metadata: ["node": "\(nodeID)"]) r = try await execCapture( containerId: nodeID, executable: kubeadmPath, diff --git a/Tests/IntegrationTests/K8s/TestK8sRunSerial.swift b/Tests/IntegrationTests/K8s/TestK8sRunSerial.swift index 04f17e02d..4996795bc 100644 --- a/Tests/IntegrationTests/K8s/TestK8sRunSerial.swift +++ b/Tests/IntegrationTests/K8s/TestK8sRunSerial.swift @@ -64,6 +64,9 @@ struct TestK8sRunSerial { print("[k8s-run] container status=\(containerStatus)") #expect(containerStatus == "running") + let checkResult = try f.run(["exec", name, "test", "-f", "/kind/kubeadm.conf"]) + #expect(checkResult.status == 0) + let kubeconfig = try loadKubeconfig() let clusters = (kubeconfig["clusters"] as? [[String: Any]]) ?? []