Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add setup hook capabilities for rke2 #2146

Merged
merged 3 commits into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/cli/cmds/server.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmds

import (
"github.com/rancher/k3s/pkg/daemons/config"
"github.com/rancher/k3s/pkg/version"
"github.com/rancher/spur/cli"
"github.com/rancher/spur/cli/altsrc"
Expand Down Expand Up @@ -54,6 +55,7 @@ type Server struct {
ClusterInit bool
ClusterReset bool
EncryptSecrets bool
StartupHooks []func(config.Control) error
}

var ServerConfig Server
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ func StartServer(ctx context.Context, config *Config) error {
return errors.Wrap(err, "starting tls server")
}

for _, hook := range config.StartupHooks {
hook(config.ControlConfig)
briandowns marked this conversation as resolved.
Show resolved Hide resolved
}

ip := net2.ParseIP(config.ControlConfig.BindAddress)
if ip == nil {
hostIP, err := net.ChooseHostInterface()
Expand Down
1 change: 1 addition & 0 deletions pkg/server/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ type Config struct {
ControlConfig config.Control
Rootless bool
SupervisorPort int
StartupHooks []func(config.Control) error
}