From 2cb6f52339a2c8d91cf713dffb4934bd70fbe23f Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Sat, 24 Aug 2019 22:27:24 -0700 Subject: [PATCH] Disable storing bootstrap information by default --- pkg/cli/cmds/server.go | 7 ++++++ pkg/cli/server/server.go | 1 + pkg/daemons/config/types.go | 43 ++++++++++++++++---------------- pkg/daemons/control/bootstrap.go | 8 +----- 4 files changed, 30 insertions(+), 29 deletions(-) diff --git a/pkg/cli/cmds/server.go b/pkg/cli/cmds/server.go index e3dc3e046e..a45859e178 100644 --- a/pkg/cli/cmds/server.go +++ b/pkg/cli/cmds/server.go @@ -22,6 +22,7 @@ type Server struct { ExtraSchedulerArgs cli.StringSlice ExtraControllerArgs cli.StringSlice Rootless bool + StoreBootstrap bool StorageEndpoint string StorageCAFile string StorageCertFile string @@ -142,6 +143,12 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command { Usage: "(experimental) Run rootless", Destination: &ServerConfig.Rootless, }, + cli.BoolFlag{ + Name: "bootstrap-save", + Usage: "(experimental) Save bootstrap information in the storage endpoint", + Hidden: true, + Destination: &ServerConfig.StoreBootstrap, + }, cli.StringFlag{ Name: "storage-endpoint", Usage: "Specify etcd, Mysql, Postgres, or Sqlite (default) data source name", diff --git a/pkg/cli/server/server.go b/pkg/cli/server/server.go index ebe7c57fe6..b35bc46da6 100644 --- a/pkg/cli/server/server.go +++ b/pkg/cli/server/server.go @@ -87,6 +87,7 @@ func run(app *cli.Context, cfg *cmds.Server) error { serverConfig.ControlConfig.Storage.KeyFile = cfg.StorageKeyFile serverConfig.ControlConfig.AdvertiseIP = cfg.AdvertiseIP serverConfig.ControlConfig.AdvertisePort = cfg.AdvertisePort + serverConfig.ControlConfig.BootstrapReadOnly = !cfg.StoreBootstrap if cmds.AgentConfig.FlannelIface != "" && cmds.AgentConfig.NodeIP == "" { cmds.AgentConfig.NodeIP = netutil.GetIPFromInterface(cmds.AgentConfig.FlannelIface) diff --git a/pkg/daemons/config/types.go b/pkg/daemons/config/types.go index 975c2647a1..08036b69ec 100644 --- a/pkg/daemons/config/types.go +++ b/pkg/daemons/config/types.go @@ -68,28 +68,27 @@ type Agent struct { } type Control struct { - AdvertisePort int - AdvertiseIP string - ListenPort int - HTTPSPort int - ClusterSecret string - ClusterIPRange *net.IPNet - ServiceIPRange *net.IPNet - ClusterDNS net.IP - ClusterDomain string - NoCoreDNS bool - KubeConfigOutput string - KubeConfigMode string - DataDir string - Skips []string - BootstrapReadOnly bool - BootstrapOverwriteLocal bool - Storage endpoint.Config - NoScheduler bool - ExtraAPIArgs []string - ExtraControllerArgs []string - ExtraSchedulerAPIArgs []string - NoLeaderElect bool + AdvertisePort int + AdvertiseIP string + ListenPort int + HTTPSPort int + ClusterSecret string + ClusterIPRange *net.IPNet + ServiceIPRange *net.IPNet + ClusterDNS net.IP + ClusterDomain string + NoCoreDNS bool + KubeConfigOutput string + KubeConfigMode string + DataDir string + Skips []string + BootstrapReadOnly bool + Storage endpoint.Config + NoScheduler bool + ExtraAPIArgs []string + ExtraControllerArgs []string + ExtraSchedulerAPIArgs []string + NoLeaderElect bool Runtime *ControlRuntime `json:"-"` } diff --git a/pkg/daemons/control/bootstrap.go b/pkg/daemons/control/bootstrap.go index 9297a6243f..8dedee6c2a 100644 --- a/pkg/daemons/control/bootstrap.go +++ b/pkg/daemons/control/bootstrap.go @@ -18,7 +18,7 @@ const ( ) // fetchBootstrapData copies the bootstrap data (certs, keys, passwords) -// from etcd to inidividual files specified by cfg.Runtime. +// from etcd to individual files specified by cfg.Runtime. func fetchBootstrapData(ctx context.Context, cfg *config.Control, c client.Client) error { logrus.Info("Fetching bootstrap data from etcd") gr, err := c.Get(ctx, k3sRuntimeEtcdPath) @@ -45,12 +45,6 @@ func fetchBootstrapData(ctx context.Context, cfg *config.Control, c client.Clien continue } - if !cfg.BootstrapOverwriteLocal { - if _, err := os.Stat(path); err == nil { - continue - } - } - if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil { return errors.Wrapf(err, "failed to mkdir %s", filepath.Dir(path)) }