Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/virtualkubelet/mesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ PersistentKeepalive = %d
// Prepare template data
data := MeshScriptTemplateData{
WGInterfaceName: wgInterfaceName,
MeshContactHost: fmt.Sprintf("%s.%s.svc.cluster.local", td.Name, td.Namespace),
WSTunnelExecutableURL: WSTunnelExecutableURL,
WireguardGoURL: wireguardGoURL,
WgToolURL: wgToolURL,
Expand Down
24 changes: 24 additions & 0 deletions pkg/virtualkubelet/mesh_template_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package virtualkubelet

import (
"bytes"
"testing"
"text/template"

"github.com/stretchr/testify/require"
)

func TestMeshTemplateExportsContactHost(t *testing.T) {
content, err := meshScriptTemplate.ReadFile("templates/mesh.sh")
require.NoError(t, err)

tmpl, err := template.New("mesh").Parse(string(content))
require.NoError(t, err)

var rendered bytes.Buffer
err = tmpl.Execute(&rendered, MeshScriptTemplateData{
MeshContactHost: "worker-tunnel.pods-wstunnel.svc.cluster.local",
})
require.NoError(t, err)
require.Contains(t, rendered.String(), `export INTERLINK_MESH_CONTACT_HOST="worker-tunnel.pods-wstunnel.svc.cluster.local"`)
}
3 changes: 2 additions & 1 deletion pkg/virtualkubelet/templates/mesh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ echo "=== Inside network namespace ==="
echo "Using WireGuard interface: $WG_IFACE"

export WG_SOCKET_DIR="$TMPDIR"
export INTERLINK_MESH_CONTACT_HOST="{{.MeshContactHost}}"

# Override /etc/resolv.conf to avoid issues with read-only filesystems
# Not all environments support this; ignore errors
Expand Down Expand Up @@ -242,4 +243,4 @@ sleep 5
echo "=== Bringing job to foreground ==="
fg 1

EOFMESH
EOFMESH
1 change: 1 addition & 0 deletions pkg/virtualkubelet/virtualkubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ type PortMapping struct {

type MeshScriptTemplateData struct {
WGInterfaceName string
MeshContactHost string
WSTunnelExecutableURL string
WireguardGoURL string
WgToolURL string
Expand Down
Loading