diff --git a/pkg/agent/config/config.go b/pkg/agent/config/config.go index 1559785b90..443b94092c 100644 --- a/pkg/agent/config/config.go +++ b/pkg/agent/config/config.go @@ -187,11 +187,9 @@ func localAddress(controlConfig *config.Control) string { return fmt.Sprintf("127.0.0.1:%d", controlConfig.ProxyPort) } -func writeKubeConfig(envInfo *cmds.Agent, info clientaccess.Info, controlConfig *config.Control, tlsCert *tls.Certificate) (string, error) { +func writeKubeConfig(envInfo *cmds.Agent, info clientaccess.Info, tlsCert *tls.Certificate) (string, error) { os.MkdirAll(envInfo.DataDir, 0700) kubeConfigPath := filepath.Join(envInfo.DataDir, "kubeconfig.yaml") - - info.URL = "https://" + localAddress(controlConfig) info.CACerts = pem.EncodeToMemory(&pem.Block{ Type: cert.CertificateBlockType, Bytes: tlsCert.Certificate[1], @@ -281,8 +279,6 @@ func get(envInfo *cmds.Agent) (*config.Node, error) { } } - proxyURL := "https://" + localAddress(controlConfig) - clientCAFile := filepath.Join(envInfo.DataDir, "client-ca.crt") if err := getHostFile(clientCAFile, info); err != nil { return nil, err @@ -301,7 +297,7 @@ func get(envInfo *cmds.Agent) (*config.Node, error) { return nil, err } - kubeconfigNode, err := writeKubeConfig(envInfo, *info, controlConfig, servingCert) + kubeconfigNode, err := writeKubeConfig(envInfo, *info, servingCert) if err != nil { return nil, err } @@ -317,7 +313,7 @@ func get(envInfo *cmds.Agent) (*config.Node, error) { } kubeconfigKubelet := filepath.Join(envInfo.DataDir, "kubelet.kubeconfig") - if err := control.KubeConfig(kubeconfigKubelet, proxyURL, serverCAFile, clientKubeletCert, clientKubeletKey); err != nil { + if err := control.KubeConfig(kubeconfigKubelet, info.URL, serverCAFile, clientKubeletCert, clientKubeletKey); err != nil { return nil, err } @@ -332,7 +328,7 @@ func get(envInfo *cmds.Agent) (*config.Node, error) { } kubeconfigKubeproxy := filepath.Join(envInfo.DataDir, "kubeproxy.kubeconfig") - if err := control.KubeConfig(kubeconfigKubeproxy, proxyURL, serverCAFile, clientKubeProxyCert, clientKubeProxyKey); err != nil { + if err := control.KubeConfig(kubeconfigKubeproxy, info.URL, serverCAFile, clientKubeProxyCert, clientKubeProxyKey); err != nil { return nil, err } diff --git a/pkg/agent/proxy/proxy.go b/pkg/agent/proxy/proxy.go deleted file mode 100644 index e93a7be39c..0000000000 --- a/pkg/agent/proxy/proxy.go +++ /dev/null @@ -1,18 +0,0 @@ -package proxy - -import ( - "github.com/google/tcpproxy" - "github.com/rancher/k3s/pkg/daemons/config" - "github.com/sirupsen/logrus" -) - -func Run(config *config.Node) error { - logrus.Infof("Starting proxy %s -> %s", config.LocalAddress, config.ServerAddress) - var proxy tcpproxy.Proxy - proxy.AddRoute(config.LocalAddress, tcpproxy.To(config.ServerAddress)) - go func() { - err := proxy.Run() - logrus.Fatalf("TLS proxy stopped: %v", err) - }() - return nil -} diff --git a/pkg/agent/run.go b/pkg/agent/run.go index cc18e3203d..640e19c26a 100644 --- a/pkg/agent/run.go +++ b/pkg/agent/run.go @@ -12,7 +12,6 @@ import ( "github.com/rancher/k3s/pkg/agent/config" "github.com/rancher/k3s/pkg/agent/containerd" "github.com/rancher/k3s/pkg/agent/flannel" - "github.com/rancher/k3s/pkg/agent/proxy" "github.com/rancher/k3s/pkg/agent/syssetup" "github.com/rancher/k3s/pkg/agent/tunnel" "github.com/rancher/k3s/pkg/cli/cmds" @@ -52,10 +51,6 @@ func run(ctx context.Context, cfg cmds.Agent) error { return err } - if err := proxy.Run(nodeConfig); err != nil { - return err - } - if err := agent.Agent(&nodeConfig.AgentConfig); err != nil { return err }