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
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",

View File

@ -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

View File

@ -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
}

View File

@ -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 {

View File

@ -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

View File

@ -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
}
}