mirror of https://github.com/k3s-io/k3s
Remove agent proxy
parent
c9b62c9a90
commit
29865fd9c9
|
@ -187,11 +187,9 @@ func localAddress(controlConfig *config.Control) string {
|
||||||
return fmt.Sprintf("127.0.0.1:%d", controlConfig.ProxyPort)
|
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)
|
os.MkdirAll(envInfo.DataDir, 0700)
|
||||||
kubeConfigPath := filepath.Join(envInfo.DataDir, "kubeconfig.yaml")
|
kubeConfigPath := filepath.Join(envInfo.DataDir, "kubeconfig.yaml")
|
||||||
|
|
||||||
info.URL = "https://" + localAddress(controlConfig)
|
|
||||||
info.CACerts = pem.EncodeToMemory(&pem.Block{
|
info.CACerts = pem.EncodeToMemory(&pem.Block{
|
||||||
Type: cert.CertificateBlockType,
|
Type: cert.CertificateBlockType,
|
||||||
Bytes: tlsCert.Certificate[1],
|
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")
|
clientCAFile := filepath.Join(envInfo.DataDir, "client-ca.crt")
|
||||||
if err := getHostFile(clientCAFile, info); err != nil {
|
if err := getHostFile(clientCAFile, info); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -301,7 +297,7 @@ func get(envInfo *cmds.Agent) (*config.Node, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
kubeconfigNode, err := writeKubeConfig(envInfo, *info, controlConfig, servingCert)
|
kubeconfigNode, err := writeKubeConfig(envInfo, *info, servingCert)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -317,7 +313,7 @@ func get(envInfo *cmds.Agent) (*config.Node, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
kubeconfigKubelet := filepath.Join(envInfo.DataDir, "kubelet.kubeconfig")
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,7 +328,7 @@ func get(envInfo *cmds.Agent) (*config.Node, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
kubeconfigKubeproxy := filepath.Join(envInfo.DataDir, "kubeproxy.kubeconfig")
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
|
||||||
}
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
"github.com/rancher/k3s/pkg/agent/config"
|
"github.com/rancher/k3s/pkg/agent/config"
|
||||||
"github.com/rancher/k3s/pkg/agent/containerd"
|
"github.com/rancher/k3s/pkg/agent/containerd"
|
||||||
"github.com/rancher/k3s/pkg/agent/flannel"
|
"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/syssetup"
|
||||||
"github.com/rancher/k3s/pkg/agent/tunnel"
|
"github.com/rancher/k3s/pkg/agent/tunnel"
|
||||||
"github.com/rancher/k3s/pkg/cli/cmds"
|
"github.com/rancher/k3s/pkg/cli/cmds"
|
||||||
|
@ -52,10 +51,6 @@ func run(ctx context.Context, cfg cmds.Agent) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := proxy.Run(nodeConfig); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := agent.Agent(&nodeConfig.AgentConfig); err != nil {
|
if err := agent.Agent(&nodeConfig.AgentConfig); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue