Skip to content

Commit

Permalink
e2e: deploy port-forwarder from go
Browse files Browse the repository at this point in the history
  • Loading branch information
burgerdev committed Mar 5, 2024
1 parent 76cf28b commit daebd55
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 31 deletions.
30 changes: 0 additions & 30 deletions deployments/openssl/portforwarder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,3 @@ spec:
memory: 50Mi
limits:
memory: 50Mi
---
apiVersion: v1
kind: Pod
metadata:
name: port-forwarder-openssl-frontend
namespace: edg-default
labels:
app.kubernetes.io/name: port-forwarder-openssl-frontend
spec:
containers:
- name: port-forwarder
image: "ghcr.io/edgelesssys/nunki/port-forwarder:latest"
env:
- name: LISTEN_PORT
value: "443"
- name: FORWARD_HOST
value: openssl-frontend
- name: FORWARD_PORT
value: "443"
command:
- /bin/bash
- "-c"
- echo Starting port-forward with socat; exec socat -d -d TCP-LISTEN:${LISTEN_PORT},fork TCP:${FORWARD_HOST}:${FORWARD_PORT}
ports:
- containerPort: 443
resources:
requests:
memory: 50Mi
limits:
memory: 50Mi
17 changes: 16 additions & 1 deletion e2e/openssl/openssl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"github.com/edgelesssys/nunki/e2e/internal/kubeclient"
"github.com/edgelesssys/nunki/e2e/internal/kuberesource"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -59,7 +60,21 @@ func TestFrontend(t *testing.T) {
namespace := os.Getenv(namespaceEnv)
require.NotEmpty(namespace, "environment variable %q must be set", namespaceEnv)

addr, cancelPortForward, err := c.PortForwardPod(ctx, namespace, "port-forwarder-openssl-frontend", "443")
pf := kuberesource.PortForwarder("openssl-frontend", namespace).
WithListenPort(443).
WithForwardTarget("openssl-frontend", 443).
PodApplyConfiguration

// TODO(burgerdev): why is the actual image not published?
img := "nixery.dev/shell/socat"
pf.Spec.Containers[0].Image = &img

res, err := kuberesource.ResourcesToUnstructured([]any{pf})
require.NoError(err)
require.NoError(c.Deploy(ctx, res...))
require.NoError(c.WaitForPod(ctx, namespace, *pf.Name))

addr, cancelPortForward, err := c.PortForwardPod(ctx, namespace, *pf.Name, "443")
require.NoError(err)
defer cancelPortForward()

Expand Down

0 comments on commit daebd55

Please sign in to comment.