Change storage to datastore

This commit is contained in:
galal-hussein 2019-11-16 02:12:27 +02:00 committed by Craig Jellick
parent bdf9dd2bca
commit 99b8222e8d
6 changed files with 39 additions and 39 deletions

View File

@ -28,10 +28,10 @@ type Server struct {
ExtraControllerArgs cli.StringSlice ExtraControllerArgs cli.StringSlice
ExtraCloudControllerArgs cli.StringSlice ExtraCloudControllerArgs cli.StringSlice
Rootless bool Rootless bool
StorageEndpoint string DatastoreEndpoint string
StorageCAFile string DatastoreCAFile string
StorageCertFile string DatastoreCertFile string
StorageKeyFile string DatastoreKeyFile string
AdvertiseIP string AdvertiseIP string
AdvertisePort int AdvertisePort int
DisableScheduler bool DisableScheduler bool
@ -163,28 +163,28 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
Value: &ServerConfig.ExtraCloudControllerArgs, Value: &ServerConfig.ExtraCloudControllerArgs,
}, },
cli.StringFlag{ cli.StringFlag{
Name: "storage-endpoint", Name: "datastore-endpoint",
Usage: "(db) Specify etcd, Mysql, Postgres, or Sqlite (default) data source name", Usage: "(db) Specify etcd, Mysql, Postgres, or Sqlite (default) data source name",
Destination: &ServerConfig.StorageEndpoint, Destination: &ServerConfig.DatastoreEndpoint,
EnvVar: "K3S_STORAGE_ENDPOINT", EnvVar: "K3S_DATASTORE_ENDPOINT",
}, },
cli.StringFlag{ cli.StringFlag{
Name: "storage-cafile", Name: "datastore-cafile",
Usage: "(db) SSL Certificate Authority file used to secure storage backend communication", Usage: "(db) TLS Certificate Authority file used to secure datastore backend communication",
Destination: &ServerConfig.StorageCAFile, Destination: &ServerConfig.DatastoreCAFile,
EnvVar: "K3S_STORAGE_CAFILE", EnvVar: "K3S_DATASTORE_CAFILE",
}, },
cli.StringFlag{ cli.StringFlag{
Name: "storage-certfile", Name: "datastore-certfile",
Usage: "(db) SSL certification file used to secure storage backend communication", Usage: "(db) TLS certification file used to secure datastore backend communication",
Destination: &ServerConfig.StorageCertFile, Destination: &ServerConfig.DatastoreCertFile,
EnvVar: "K3S_STORAGE_CERTFILE", EnvVar: "K3S_DATASTORE_CERTFILE",
}, },
cli.StringFlag{ cli.StringFlag{
Name: "storage-keyfile", Name: "datastore-keyfile",
Usage: "(db) SSL key file used to secure storage backend communication", Usage: "(db) TLS key file used to secure datastore backend communication",
Destination: &ServerConfig.StorageKeyFile, Destination: &ServerConfig.DatastoreKeyFile,
EnvVar: "K3S_STORAGE_KEYFILE", EnvVar: "K3S_DATASTORE_KEYFILE",
}, },
cli.StringFlag{ cli.StringFlag{
Name: "default-local-storage-path", Name: "default-local-storage-path",

View File

@ -88,10 +88,10 @@ func run(app *cli.Context, cfg *cmds.Server) error {
serverConfig.ControlConfig.ExtraControllerArgs = cfg.ExtraControllerArgs serverConfig.ControlConfig.ExtraControllerArgs = cfg.ExtraControllerArgs
serverConfig.ControlConfig.ExtraSchedulerAPIArgs = cfg.ExtraSchedulerArgs serverConfig.ControlConfig.ExtraSchedulerAPIArgs = cfg.ExtraSchedulerArgs
serverConfig.ControlConfig.ClusterDomain = cfg.ClusterDomain serverConfig.ControlConfig.ClusterDomain = cfg.ClusterDomain
serverConfig.ControlConfig.Storage.Endpoint = cfg.StorageEndpoint serverConfig.ControlConfig.Datastore.Endpoint = cfg.DatastoreEndpoint
serverConfig.ControlConfig.Storage.CAFile = cfg.StorageCAFile serverConfig.ControlConfig.Datastore.CAFile = cfg.DatastoreCAFile
serverConfig.ControlConfig.Storage.CertFile = cfg.StorageCertFile serverConfig.ControlConfig.Datastore.CertFile = cfg.DatastoreCertFile
serverConfig.ControlConfig.Storage.KeyFile = cfg.StorageKeyFile serverConfig.ControlConfig.Datastore.KeyFile = cfg.DatastoreKeyFile
serverConfig.ControlConfig.AdvertiseIP = cfg.AdvertiseIP serverConfig.ControlConfig.AdvertiseIP = cfg.AdvertiseIP
serverConfig.ControlConfig.AdvertisePort = cfg.AdvertisePort serverConfig.ControlConfig.AdvertisePort = cfg.AdvertisePort
serverConfig.ControlConfig.FlannelBackend = cfg.FlannelBackend serverConfig.ControlConfig.FlannelBackend = cfg.FlannelBackend

View File

@ -59,14 +59,14 @@ func (c *Cluster) startStorage(ctx context.Context) error {
} }
c.storageStarted = true c.storageStarted = true
etcdConfig, err := endpoint.Listen(ctx, c.config.Storage) etcdConfig, err := endpoint.Listen(ctx, c.config.Datastore)
if err != nil { if err != nil {
return err return err
} }
c.etcdConfig = etcdConfig c.etcdConfig = etcdConfig
c.config.Storage.Config = etcdConfig.TLSConfig c.config.Datastore.Config = etcdConfig.TLSConfig
c.config.Storage.Endpoint = strings.Join(etcdConfig.Endpoints, ",") c.config.Datastore.Endpoint = strings.Join(etcdConfig.Endpoints, ",")
c.config.NoLeaderElect = !etcdConfig.LeaderElect c.config.NoLeaderElect = !etcdConfig.LeaderElect
return nil return nil
} }

View File

@ -76,8 +76,8 @@ func (c *Cluster) initClusterDB(ctx context.Context, l net.Listener, handler htt
} }
c.db = dqlite c.db = dqlite
if !strings.HasPrefix(c.config.Storage.Endpoint, "dqlite://") { if !strings.HasPrefix(c.config.Datastore.Endpoint, "dqlite://") {
c.config.Storage = endpoint.Config{ c.config.Datastore = endpoint.Config{
Endpoint: dqlite.StorageEndpoint, Endpoint: dqlite.StorageEndpoint,
} }
} }
@ -91,12 +91,12 @@ func (c *Cluster) dqliteEnabled() bool {
return true return true
} }
driver, _ := endpoint.ParseStorageEndpoint(c.config.Storage.Endpoint) driver, _ := endpoint.ParseStorageEndpoint(c.config.Datastore.Endpoint)
if driver == endpoint.DQLiteBackend { if driver == endpoint.DQLiteBackend {
return true 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 { func (c *Cluster) postJoin(ctx context.Context) error {

View File

@ -96,7 +96,7 @@ type Control struct {
KubeConfigMode string KubeConfigMode string
DataDir string DataDir string
Skips []string Skips []string
Storage endpoint.Config Datastore endpoint.Config
NoScheduler bool NoScheduler bool
ExtraAPIArgs []string ExtraAPIArgs []string
ExtraControllerArgs []string ExtraControllerArgs []string

View File

@ -745,18 +745,18 @@ func KubeConfig(dest, url, caCert, clientCert, clientKey string) error {
func setupStorageBackend(argsMap map[string]string, cfg *config.Control) { func setupStorageBackend(argsMap map[string]string, cfg *config.Control) {
argsMap["storage-backend"] = "etcd3" argsMap["storage-backend"] = "etcd3"
// specify the endpoints // specify the endpoints
if len(cfg.Storage.Endpoint) > 0 { if len(cfg.Datastore.Endpoint) > 0 {
argsMap["etcd-servers"] = cfg.Storage.Endpoint argsMap["etcd-servers"] = cfg.Datastore.Endpoint
} }
// storage backend tls configuration // storage backend tls configuration
if len(cfg.Storage.CAFile) > 0 { if len(cfg.Datastore.CAFile) > 0 {
argsMap["etcd-cafile"] = cfg.Storage.CAFile argsMap["etcd-cafile"] = cfg.Datastore.CAFile
} }
if len(cfg.Storage.CertFile) > 0 { if len(cfg.Datastore.CertFile) > 0 {
argsMap["etcd-certfile"] = cfg.Storage.CertFile argsMap["etcd-certfile"] = cfg.Datastore.CertFile
} }
if len(cfg.Storage.KeyFile) > 0 { if len(cfg.Datastore.KeyFile) > 0 {
argsMap["etcd-keyfile"] = cfg.Storage.KeyFile argsMap["etcd-keyfile"] = cfg.Datastore.KeyFile
} }
} }