1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-16 15:21:33 +00:00
Files
norman/pkg/kwrapper/k8s/tunnel_k3s.go
Darren Shepherd 9b1f7db6f0 Fix k3s issues
2018-10-24 16:21:28 -07:00

27 lines
623 B
Go

// +build k8s
package k8s
import (
"context"
"net"
"time"
"github.com/rancher/norman/pkg/kv"
"github.com/rancher/norman/pkg/remotedialer"
utilnet "k8s.io/apimachinery/pkg/util/net"
"k8s.io/kubernetes/cmd/kube-apiserver/app"
)
func setupK3s(tunnelServer *remotedialer.Server) {
app.DefaultProxyDialerFn = utilnet.DialFunc(func(_ context.Context, network, address string) (net.Conn, error) {
_, port, _ := net.SplitHostPort(address)
addr := "127.0.0.1"
if port != "" {
addr += ":" + port
}
nodeName, _ := kv.Split(address, ":")
return tunnelServer.Dial(nodeName, 15*time.Second, "tcp", addr)
})
}