mirror of https://github.com/k3s-io/k3s
commit
5deef13086
|
@ -11,7 +11,6 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/rancher/dynamiclistener"
|
"github.com/rancher/dynamiclistener"
|
||||||
|
@ -72,7 +71,6 @@ func StartServer(ctx context.Context, config *Config) (string, error) {
|
||||||
func startWrangler(ctx context.Context, config *Config) (string, error) {
|
func startWrangler(ctx context.Context, config *Config) (string, error) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
tlsServer dynamiclistener.ServerInterface
|
|
||||||
tlsConfig = &config.TLSConfig
|
tlsConfig = &config.TLSConfig
|
||||||
controlConfig = &config.ControlConfig
|
controlConfig = &config.ControlConfig
|
||||||
)
|
)
|
||||||
|
@ -86,14 +84,12 @@ func startWrangler(ctx context.Context, config *Config) (string, error) {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
tlsConfig.CACerts = string(caBytes)
|
certs := string(caBytes)
|
||||||
|
tlsConfig.CACerts = certs
|
||||||
tlsConfig.CAKey = string(caKeyBytes)
|
tlsConfig.CAKey = string(caKeyBytes)
|
||||||
|
|
||||||
tlsConfig.Handler = router(controlConfig, controlConfig.Runtime.Tunnel, func() (string, error) {
|
tlsConfig.Handler = router(controlConfig, controlConfig.Runtime.Tunnel, func() (string, error) {
|
||||||
if tlsServer == nil {
|
return certs, nil
|
||||||
return "", nil
|
|
||||||
}
|
|
||||||
return tlsServer.CACert()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
sc, err := newContext(ctx, controlConfig.Runtime.KubeConfigAdmin)
|
sc, err := newContext(ctx, controlConfig.Runtime.KubeConfigAdmin)
|
||||||
|
@ -105,7 +101,7 @@ func startWrangler(ctx context.Context, config *Config) (string, error) {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
tlsServer, err = tls.NewServer(ctx, sc.K3s.K3s().V1().ListenerConfig(), *tlsConfig)
|
_, err = tls.NewServer(ctx, sc.K3s.K3s().V1().ListenerConfig(), *tlsConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -114,16 +110,6 @@ func startWrangler(ctx context.Context, config *Config) (string, error) {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
certs := ""
|
|
||||||
for certs == "" {
|
|
||||||
certs, err = tlsServer.CACert()
|
|
||||||
if err != nil {
|
|
||||||
logrus.Infof("waiting to generate CA certs")
|
|
||||||
time.Sleep(time.Second)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
go leader.RunOrDie(ctx, "", "k3s", sc.K8s, func(ctx context.Context) {
|
go leader.RunOrDie(ctx, "", "k3s", sc.K8s, func(ctx context.Context) {
|
||||||
if err := masterControllers(ctx, sc, config); err != nil {
|
if err := masterControllers(ctx, sc, config); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
Loading…
Reference in New Issue