From 99b8222e8df034b5450eaac9bd21abd5462b6d56 Mon Sep 17 00:00:00 2001 From: galal-hussein Date: Sat, 16 Nov 2019 02:12:27 +0200 Subject: [PATCH] Change storage to datastore --- pkg/cli/cmds/server.go | 38 +++++++++++++++++------------------ pkg/cli/server/server.go | 8 ++++---- pkg/cluster/cluster.go | 6 +++--- pkg/cluster/dqlite.go | 8 ++++---- pkg/daemons/config/types.go | 2 +- pkg/daemons/control/server.go | 16 +++++++-------- 6 files changed, 39 insertions(+), 39 deletions(-) diff --git a/pkg/cli/cmds/server.go b/pkg/cli/cmds/server.go index 19cdecf439..26a63174d7 100644 --- a/pkg/cli/cmds/server.go +++ b/pkg/cli/cmds/server.go @@ -28,10 +28,10 @@ type Server struct { ExtraControllerArgs cli.StringSlice ExtraCloudControllerArgs cli.StringSlice Rootless bool - StorageEndpoint string - StorageCAFile string - StorageCertFile string - StorageKeyFile string + DatastoreEndpoint string + DatastoreCAFile string + DatastoreCertFile string + DatastoreKeyFile string AdvertiseIP string AdvertisePort int DisableScheduler bool @@ -163,28 +163,28 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command { Value: &ServerConfig.ExtraCloudControllerArgs, }, cli.StringFlag{ - Name: "storage-endpoint", + Name: "datastore-endpoint", Usage: "(db) Specify etcd, Mysql, Postgres, or Sqlite (default) data source name", - Destination: &ServerConfig.StorageEndpoint, - EnvVar: "K3S_STORAGE_ENDPOINT", + Destination: &ServerConfig.DatastoreEndpoint, + EnvVar: "K3S_DATASTORE_ENDPOINT", }, cli.StringFlag{ - Name: "storage-cafile", - Usage: "(db) SSL Certificate Authority file used to secure storage backend communication", - Destination: &ServerConfig.StorageCAFile, - EnvVar: "K3S_STORAGE_CAFILE", + Name: "datastore-cafile", + Usage: "(db) TLS Certificate Authority file used to secure datastore backend communication", + Destination: &ServerConfig.DatastoreCAFile, + EnvVar: "K3S_DATASTORE_CAFILE", }, cli.StringFlag{ - Name: "storage-certfile", - Usage: "(db) SSL certification file used to secure storage backend communication", - Destination: &ServerConfig.StorageCertFile, - EnvVar: "K3S_STORAGE_CERTFILE", + Name: "datastore-certfile", + Usage: "(db) TLS certification file used to secure datastore backend communication", + Destination: &ServerConfig.DatastoreCertFile, + EnvVar: "K3S_DATASTORE_CERTFILE", }, cli.StringFlag{ - Name: "storage-keyfile", - Usage: "(db) SSL key file used to secure storage backend communication", - Destination: &ServerConfig.StorageKeyFile, - EnvVar: "K3S_STORAGE_KEYFILE", + Name: "datastore-keyfile", + Usage: "(db) TLS key file used to secure datastore backend communication", + Destination: &ServerConfig.DatastoreKeyFile, + EnvVar: "K3S_DATASTORE_KEYFILE", }, cli.StringFlag{ Name: "default-local-storage-path", diff --git a/pkg/cli/server/server.go b/pkg/cli/server/server.go index c6f4d577a0..dbf27eb298 100644 --- a/pkg/cli/server/server.go +++ b/pkg/cli/server/server.go @@ -88,10 +88,10 @@ func run(app *cli.Context, cfg *cmds.Server) error { serverConfig.ControlConfig.ExtraControllerArgs = cfg.ExtraControllerArgs serverConfig.ControlConfig.ExtraSchedulerAPIArgs = cfg.ExtraSchedulerArgs serverConfig.ControlConfig.ClusterDomain = cfg.ClusterDomain - serverConfig.ControlConfig.Storage.Endpoint = cfg.StorageEndpoint - serverConfig.ControlConfig.Storage.CAFile = cfg.StorageCAFile - serverConfig.ControlConfig.Storage.CertFile = cfg.StorageCertFile - serverConfig.ControlConfig.Storage.KeyFile = cfg.StorageKeyFile + serverConfig.ControlConfig.Datastore.Endpoint = cfg.DatastoreEndpoint + serverConfig.ControlConfig.Datastore.CAFile = cfg.DatastoreCAFile + serverConfig.ControlConfig.Datastore.CertFile = cfg.DatastoreCertFile + serverConfig.ControlConfig.Datastore.KeyFile = cfg.DatastoreKeyFile serverConfig.ControlConfig.AdvertiseIP = cfg.AdvertiseIP serverConfig.ControlConfig.AdvertisePort = cfg.AdvertisePort serverConfig.ControlConfig.FlannelBackend = cfg.FlannelBackend diff --git a/pkg/cluster/cluster.go b/pkg/cluster/cluster.go index 580d40d75d..50f4fae01c 100644 --- a/pkg/cluster/cluster.go +++ b/pkg/cluster/cluster.go @@ -59,14 +59,14 @@ func (c *Cluster) startStorage(ctx context.Context) error { } c.storageStarted = true - etcdConfig, err := endpoint.Listen(ctx, c.config.Storage) + etcdConfig, err := endpoint.Listen(ctx, c.config.Datastore) if err != nil { return err } c.etcdConfig = etcdConfig - c.config.Storage.Config = etcdConfig.TLSConfig - c.config.Storage.Endpoint = strings.Join(etcdConfig.Endpoints, ",") + c.config.Datastore.Config = etcdConfig.TLSConfig + c.config.Datastore.Endpoint = strings.Join(etcdConfig.Endpoints, ",") c.config.NoLeaderElect = !etcdConfig.LeaderElect return nil } diff --git a/pkg/cluster/dqlite.go b/pkg/cluster/dqlite.go index faeb80f994..c41d05d05d 100644 --- a/pkg/cluster/dqlite.go +++ b/pkg/cluster/dqlite.go @@ -76,8 +76,8 @@ func (c *Cluster) initClusterDB(ctx context.Context, l net.Listener, handler htt } c.db = dqlite - if !strings.HasPrefix(c.config.Storage.Endpoint, "dqlite://") { - c.config.Storage = endpoint.Config{ + if !strings.HasPrefix(c.config.Datastore.Endpoint, "dqlite://") { + c.config.Datastore = endpoint.Config{ Endpoint: dqlite.StorageEndpoint, } } @@ -91,12 +91,12 @@ func (c *Cluster) dqliteEnabled() bool { return true } - driver, _ := endpoint.ParseStorageEndpoint(c.config.Storage.Endpoint) + driver, _ := endpoint.ParseStorageEndpoint(c.config.Datastore.Endpoint) if driver == endpoint.DQLiteBackend { return true } - return c.config.Storage.Endpoint == "" && (c.config.ClusterInit || (c.config.Token != "" && c.config.JoinURL != "")) + return c.config.Datastore.Endpoint == "" && (c.config.ClusterInit || (c.config.Token != "" && c.config.JoinURL != "")) } func (c *Cluster) postJoin(ctx context.Context) error { diff --git a/pkg/daemons/config/types.go b/pkg/daemons/config/types.go index cac96859e6..d1f23fc9d1 100644 --- a/pkg/daemons/config/types.go +++ b/pkg/daemons/config/types.go @@ -96,7 +96,7 @@ type Control struct { KubeConfigMode string DataDir string Skips []string - Storage endpoint.Config + Datastore endpoint.Config NoScheduler bool ExtraAPIArgs []string ExtraControllerArgs []string diff --git a/pkg/daemons/control/server.go b/pkg/daemons/control/server.go index 9394a05318..62d3b1fe94 100644 --- a/pkg/daemons/control/server.go +++ b/pkg/daemons/control/server.go @@ -745,18 +745,18 @@ func KubeConfig(dest, url, caCert, clientCert, clientKey string) error { func setupStorageBackend(argsMap map[string]string, cfg *config.Control) { argsMap["storage-backend"] = "etcd3" // specify the endpoints - if len(cfg.Storage.Endpoint) > 0 { - argsMap["etcd-servers"] = cfg.Storage.Endpoint + if len(cfg.Datastore.Endpoint) > 0 { + argsMap["etcd-servers"] = cfg.Datastore.Endpoint } // storage backend tls configuration - if len(cfg.Storage.CAFile) > 0 { - argsMap["etcd-cafile"] = cfg.Storage.CAFile + if len(cfg.Datastore.CAFile) > 0 { + argsMap["etcd-cafile"] = cfg.Datastore.CAFile } - if len(cfg.Storage.CertFile) > 0 { - argsMap["etcd-certfile"] = cfg.Storage.CertFile + if len(cfg.Datastore.CertFile) > 0 { + argsMap["etcd-certfile"] = cfg.Datastore.CertFile } - if len(cfg.Storage.KeyFile) > 0 { - argsMap["etcd-keyfile"] = cfg.Storage.KeyFile + if len(cfg.Datastore.KeyFile) > 0 { + argsMap["etcd-keyfile"] = cfg.Datastore.KeyFile } }