Merge pull request #2146 from briandowns/add_hook_for_rke2

add setup hook capabilities for rke2
This commit is contained in:
Brian Downs 2020-08-19 19:42:50 -07:00 committed by GitHub
commit a2471a1f8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 0 deletions

View File

@ -1,6 +1,9 @@
package cmds
import (
"context"
"github.com/rancher/k3s/pkg/daemons/config"
"github.com/rancher/k3s/pkg/version"
"github.com/rancher/spur/cli"
"github.com/rancher/spur/cli/altsrc"
@ -54,6 +57,7 @@ type Server struct {
ClusterInit bool
ClusterReset bool
EncryptSecrets bool
StartupHooks []func(context.Context, config.Control) error
}
var ServerConfig Server

View File

@ -193,6 +193,8 @@ func run(app *cli.Context, cfg *cmds.Server) error {
return errors.Wrap(err, "Invalid tls-min-version")
}
serverConfig.StartupHooks = append(serverConfig.StartupHooks, cfg.StartupHooks...)
// TLS config based on mozilla ssl-config generator
// https://ssl-config.mozilla.org/#server=golang&version=1.13.6&config=intermediate&guideline=5.4
// Need to disable the TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 Cipher for TLS1.2

View File

@ -60,6 +60,12 @@ func StartServer(ctx context.Context, config *Config) error {
return errors.Wrap(err, "starting tls server")
}
for _, hook := range config.StartupHooks {
if err := hook(ctx, config.ControlConfig); err != nil {
return errors.Wrap(err, "startup hook")
}
}
ip := net2.ParseIP(config.ControlConfig.BindAddress)
if ip == nil {
hostIP, err := net.ChooseHostInterface()

View File

@ -1,6 +1,8 @@
package server
import (
"context"
"github.com/rancher/k3s/pkg/daemons/config"
)
@ -10,4 +12,5 @@ type Config struct {
ControlConfig config.Control
Rootless bool
SupervisorPort int
StartupHooks []func(context.Context, config.Control) error
}