From eac018557968eb36c52112a093d7ab40c2391528 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Mon, 10 Jan 2022 11:19:55 +0100 Subject: [PATCH] Test that kubeconfig returns externalAddress Add a test to verify that the server address is set to externalAddress when it is set, and that the custom ports are included in the kubeconfig. This is a test for issue https://github.com/k0sproject/k0s/issues/1202 Signed-off-by: Natanael Copa --- inttest/customports/customports_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/inttest/customports/customports_test.go b/inttest/customports/customports_test.go index b5b37b80def9..08fe7ec4a262 100644 --- a/inttest/customports/customports_test.go +++ b/inttest/customports/customports_test.go @@ -19,6 +19,7 @@ package customports import ( "bytes" "context" + "fmt" "html/template" "testing" @@ -135,4 +136,15 @@ func (ds *Suite) TestControllerJoinsWithCustomPort() { ds.T().Log("waiting to get logs from pods") ds.Require().NoError(common.WaitForPodLogs(kc, "kube-system")) + + // https://github.com/k0sproject/k0s/issues/1202 + ds.T().Log("test that kubeconfig includes externalAddress") + ssh, err := ds.SSH(ds.ControllerNode(0)) + ds.Require().NoError(err) + defer ssh.Disconnect() + + out, err := ssh.ExecWithOutput("k0s kubeconfig create user | awk '$1 == \"server:\" {print $2}'") + ds.Require().NoError(err) + ds.Require().Equal(fmt.Sprintf("https://%s:%d", ipAddress, kubeAPIPort), out) + }