From e10524a6b182ebda0eb659366846cdc66c1fd98e Mon Sep 17 00:00:00 2001 From: Brad Davidson Date: Tue, 11 May 2021 12:50:08 -0700 Subject: [PATCH] Add executor.Bootstrap hook for pre-execution setup Signed-off-by: Brad Davidson --- pkg/agent/run.go | 5 +++++ pkg/daemons/executor/embed.go | 6 ++++++ pkg/daemons/executor/executor.go | 7 +++++++ 3 files changed, 18 insertions(+) diff --git a/pkg/agent/run.go b/pkg/agent/run.go index 21de502cc4..9b8449f167 100644 --- a/pkg/agent/run.go +++ b/pkg/agent/run.go @@ -26,6 +26,7 @@ import ( cp "github.com/rancher/k3s/pkg/cloudprovider" "github.com/rancher/k3s/pkg/daemons/agent" daemonconfig "github.com/rancher/k3s/pkg/daemons/config" + "github.com/rancher/k3s/pkg/daemons/executor" "github.com/rancher/k3s/pkg/nodeconfig" "github.com/rancher/k3s/pkg/rootless" "github.com/rancher/k3s/pkg/util" @@ -91,6 +92,10 @@ func run(ctx context.Context, cfg cmds.Agent, proxy proxy.Proxy) error { return err } + if err := executor.Bootstrap(ctx, nodeConfig, cfg); err != nil { + return err + } + if !nodeConfig.NoFlannel { if err := flannel.Prepare(ctx, nodeConfig); err != nil { return err diff --git a/pkg/daemons/executor/embed.go b/pkg/daemons/executor/embed.go index 90e04bf1f1..515988e467 100644 --- a/pkg/daemons/executor/embed.go +++ b/pkg/daemons/executor/embed.go @@ -11,6 +11,8 @@ import ( proxy "k8s.io/kubernetes/cmd/kube-proxy/app" kubelet "k8s.io/kubernetes/cmd/kubelet/app" + "github.com/rancher/k3s/pkg/cli/cmds" + daemonconfig "github.com/rancher/k3s/pkg/daemons/config" "github.com/sirupsen/logrus" "k8s.io/kubernetes/cmd/kube-apiserver/app" cmapp "k8s.io/kubernetes/cmd/kube-controller-manager/app" @@ -23,6 +25,10 @@ func init() { type Embedded struct{} +func (Embedded) Bootstrap(ctx context.Context, nodeConfig *daemonconfig.Node, cfg cmds.Agent) error { + return nil +} + func (Embedded) Kubelet(args []string) error { command := kubelet.NewKubeletCommand(context.Background()) command.SetArgs(args) diff --git a/pkg/daemons/executor/executor.go b/pkg/daemons/executor/executor.go index 9d1d31065d..3c4bf80500 100644 --- a/pkg/daemons/executor/executor.go +++ b/pkg/daemons/executor/executor.go @@ -9,6 +9,8 @@ import ( "sigs.k8s.io/yaml" + "github.com/rancher/k3s/pkg/cli/cmds" + daemonconfig "github.com/rancher/k3s/pkg/daemons/config" "k8s.io/apiserver/pkg/authentication/authenticator" ) @@ -17,6 +19,7 @@ var ( ) type Executor interface { + Bootstrap(ctx context.Context, nodeConfig *daemonconfig.Node, cfg cmds.Agent) error Kubelet(args []string) error KubeProxy(args []string) error APIServer(ctx context.Context, etcdReady <-chan struct{}, args []string) (authenticator.Request, http.Handler, error) @@ -81,6 +84,10 @@ func Set(driver Executor) { executor = driver } +func Bootstrap(ctx context.Context, nodeConfig *daemonconfig.Node, cfg cmds.Agent) error { + return executor.Bootstrap(ctx, nodeConfig, cfg) +} + func Kubelet(args []string) error { return executor.Kubelet(args) }