Disable storing bootstrap information by default

pull/707/head
Darren Shepherd 2019-08-24 22:27:24 -07:00
parent a005219c5b
commit 2cb6f52339
4 changed files with 30 additions and 29 deletions

View File

@ -22,6 +22,7 @@ type Server struct {
ExtraSchedulerArgs cli.StringSlice ExtraSchedulerArgs cli.StringSlice
ExtraControllerArgs cli.StringSlice ExtraControllerArgs cli.StringSlice
Rootless bool Rootless bool
StoreBootstrap bool
StorageEndpoint string StorageEndpoint string
StorageCAFile string StorageCAFile string
StorageCertFile string StorageCertFile string
@ -142,6 +143,12 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
Usage: "(experimental) Run rootless", Usage: "(experimental) Run rootless",
Destination: &ServerConfig.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{ cli.StringFlag{
Name: "storage-endpoint", Name: "storage-endpoint",
Usage: "Specify etcd, Mysql, Postgres, or Sqlite (default) data source name", Usage: "Specify etcd, Mysql, Postgres, or Sqlite (default) data source name",

View File

@ -87,6 +87,7 @@ func run(app *cli.Context, cfg *cmds.Server) error {
serverConfig.ControlConfig.Storage.KeyFile = cfg.StorageKeyFile serverConfig.ControlConfig.Storage.KeyFile = cfg.StorageKeyFile
serverConfig.ControlConfig.AdvertiseIP = cfg.AdvertiseIP serverConfig.ControlConfig.AdvertiseIP = cfg.AdvertiseIP
serverConfig.ControlConfig.AdvertisePort = cfg.AdvertisePort serverConfig.ControlConfig.AdvertisePort = cfg.AdvertisePort
serverConfig.ControlConfig.BootstrapReadOnly = !cfg.StoreBootstrap
if cmds.AgentConfig.FlannelIface != "" && cmds.AgentConfig.NodeIP == "" { if cmds.AgentConfig.FlannelIface != "" && cmds.AgentConfig.NodeIP == "" {
cmds.AgentConfig.NodeIP = netutil.GetIPFromInterface(cmds.AgentConfig.FlannelIface) cmds.AgentConfig.NodeIP = netutil.GetIPFromInterface(cmds.AgentConfig.FlannelIface)

View File

@ -68,28 +68,27 @@ type Agent struct {
} }
type Control struct { type Control struct {
AdvertisePort int AdvertisePort int
AdvertiseIP string AdvertiseIP string
ListenPort int ListenPort int
HTTPSPort int HTTPSPort int
ClusterSecret string ClusterSecret string
ClusterIPRange *net.IPNet ClusterIPRange *net.IPNet
ServiceIPRange *net.IPNet ServiceIPRange *net.IPNet
ClusterDNS net.IP ClusterDNS net.IP
ClusterDomain string ClusterDomain string
NoCoreDNS bool NoCoreDNS bool
KubeConfigOutput string KubeConfigOutput string
KubeConfigMode string KubeConfigMode string
DataDir string DataDir string
Skips []string Skips []string
BootstrapReadOnly bool BootstrapReadOnly bool
BootstrapOverwriteLocal bool Storage endpoint.Config
Storage endpoint.Config NoScheduler bool
NoScheduler bool ExtraAPIArgs []string
ExtraAPIArgs []string ExtraControllerArgs []string
ExtraControllerArgs []string ExtraSchedulerAPIArgs []string
ExtraSchedulerAPIArgs []string NoLeaderElect bool
NoLeaderElect bool
Runtime *ControlRuntime `json:"-"` Runtime *ControlRuntime `json:"-"`
} }

View File

@ -18,7 +18,7 @@ const (
) )
// fetchBootstrapData copies the bootstrap data (certs, keys, passwords) // 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 { func fetchBootstrapData(ctx context.Context, cfg *config.Control, c client.Client) error {
logrus.Info("Fetching bootstrap data from etcd") logrus.Info("Fetching bootstrap data from etcd")
gr, err := c.Get(ctx, k3sRuntimeEtcdPath) gr, err := c.Get(ctx, k3sRuntimeEtcdPath)
@ -45,12 +45,6 @@ func fetchBootstrapData(ctx context.Context, cfg *config.Control, c client.Clien
continue continue
} }
if !cfg.BootstrapOverwriteLocal {
if _, err := os.Stat(path); err == nil {
continue
}
}
if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil { if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {
return errors.Wrapf(err, "failed to mkdir %s", filepath.Dir(path)) return errors.Wrapf(err, "failed to mkdir %s", filepath.Dir(path))
} }