Skip to content

Commit 451747b

Browse files
authored
Extra port added for test cluster to make ingress port reachable (#1308)
* Extra port added to make ingress port reachable Signed-off-by: Alexey Makhov <amakhov@mirantis.com> Signed-off-by: makhov <amakhov@mirantis.com> * Extra port added to make ingress port reachable. Change hosting cluster api port to non-default Signed-off-by: Alexey Makhov <amakhov@mirantis.com> Signed-off-by: makhov <amakhov@mirantis.com> --------- Signed-off-by: Alexey Makhov <amakhov@mirantis.com> Signed-off-by: makhov <amakhov@mirantis.com>
1 parent ee79f00 commit 451747b

File tree

5 files changed

+28
-12
lines changed

5 files changed

+28
-12
lines changed

e2e/data/infrastructure-docker/main/cluster-template-ingress/cluster-with-ingress.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ metadata:
2828
name: ${CLUSTER_NAME}-cp
2929
spec:
3030
version: v1.34.1-k0s.0
31+
service:
32+
type: NodePort
3133
ingress:
3234
apiHost: kube-api.${KIND_IP}.nip.io
3335
konnectivityHost: konnectivity.${KIND_IP}.nip.io

e2e/data/infrastructure-docker/main/cluster-template-remote-hcp/hcp-with-external-cluster-patch.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ spec:
1212
version: v1.30.1-k0s.0
1313
service:
1414
type: NodePort
15+
apiPort: 31443
1516

1617
k0sConfig:
1718
apiVersion: k0s.k0sproject.io/v1beta1

e2e/ingress_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ import (
2323
"fmt"
2424
"github.com/k0sproject/k0s/inttest/common"
2525
"k8s.io/client-go/kubernetes"
26+
"k8s.io/client-go/rest"
2627
"os/exec"
2728
"path/filepath"
2829
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
29-
"sigs.k8s.io/cluster-api/controllers/remote"
3030
"sigs.k8s.io/controller-runtime/pkg/client"
3131
"testing"
3232
"time"
@@ -156,9 +156,10 @@ func ingressSupportSpec(t *testing.T) {
156156
clusterv1.ClusterNameLabel: workloadClusterName,
157157
}), "Should list machines")
158158

159-
wrc, err := remote.RESTConfig(ctx, "ingress-test", bootstrapClusterProxy.GetClient(), client.ObjectKey{Namespace: workloadClusterNamespace, Name: workloadClusterName})
160-
require.NoError(t, err, "Should get workload rest config")
161-
wcs, err := kubernetes.NewForConfig(wrc)
159+
workloadCluster := bootstrapClusterProxy.GetWorkloadCluster(ctx, workloadClusterNamespace, workloadClusterName, capiframework.WithRESTConfigModifier(func(config *rest.Config) {
160+
config.Host = "https://localhost:30443"
161+
}))
162+
wcs, err := kubernetes.NewForConfig(workloadCluster.GetRESTConfig())
162163
require.NoError(t, err, "Should get workload clientset")
163164
require.NoError(t, common.WaitForDaemonSet(ctx, wcs, "konnectivity-agent"))
164165

@@ -167,7 +168,8 @@ func ingressSupportSpec(t *testing.T) {
167168
require.NoError(t, err, "Should list k0smotron pods")
168169
out, err := podexec.PodExecCmdOutput(ctx, bootstrapClusterProxy.GetClientSet(), bootstrapClusterProxy.GetRESTConfig(), podList.Items[0].Name, testNamespace.Name, "k0s kc logs -n kube-system ds/konnectivity-agent")
169170
require.NoError(t, err)
170-
t.Logf("Konnectivity agent logs:\n%s", string(out))
171+
t.Logf("Konnectivity agent logs:\n%s", out)
172+
require.Contains(t, out, "change detected in proxy")
171173

172174
for _, m := range machineList.Items {
173175
var (

e2e/remote_hcp_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ func deployHostingCluster() {
241241
LogFolder: filepath.Join(artifactFolder, "kind"),
242242
ExtraPortMappings: []v1alpha4.PortMapping{
243243
{
244-
ContainerPort: 30443,
245-
HostPort: 30443,
244+
ContainerPort: 31443,
245+
HostPort: 31443,
246246
},
247247
},
248248
})

e2e/setup.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,17 @@ import (
3131

3232
"k8s.io/apimachinery/pkg/runtime"
3333
"k8s.io/klog/v2"
34-
"sigs.k8s.io/yaml"
35-
36-
cpv1beta1 "github.com/k0sproject/k0smotron/api/controlplane/v1beta1"
37-
"github.com/k0sproject/k0smotron/e2e/mothership"
38-
"github.com/k0sproject/k0smotron/e2e/util"
3934
"sigs.k8s.io/cluster-api/test/framework"
4035
capiframework "sigs.k8s.io/cluster-api/test/framework"
4136
"sigs.k8s.io/cluster-api/test/framework/bootstrap"
4237
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
4338
ctrl "sigs.k8s.io/controller-runtime"
39+
"sigs.k8s.io/kind/pkg/apis/config/v1alpha4"
40+
"sigs.k8s.io/yaml"
41+
42+
cpv1beta1 "github.com/k0sproject/k0smotron/api/controlplane/v1beta1"
43+
"github.com/k0sproject/k0smotron/e2e/mothership"
44+
"github.com/k0sproject/k0smotron/e2e/util"
4445
)
4546

4647
// Test suite constants for e2e config variables.
@@ -153,6 +154,16 @@ func setupMothership() error {
153154
RequiresDockerSock: e2eConfig.HasDockerProvider(),
154155
IPFamily: e2eConfig.MustGetVariable(IPFamily),
155156
LogFolder: filepath.Join(artifactFolder, "kind"),
157+
ExtraPortMappings: []v1alpha4.PortMapping{
158+
{
159+
ContainerPort: 32143, // haproxy ingress port
160+
HostPort: 32143,
161+
},
162+
{
163+
ContainerPort: 30443, // HCP api nodeport
164+
HostPort: 30443,
165+
},
166+
},
156167
})
157168
if bootstrapClusterProvider == nil {
158169
return errors.New("failed to create a management cluster")

0 commit comments

Comments
 (0)