mirror of https://github.com/k3s-io/k3s
Add storage backend flags
parent
e82b62cbab
commit
17d8708ca5
|
@ -23,7 +23,11 @@ type Server struct {
|
|||
ExtraSchedulerArgs cli.StringSlice
|
||||
ExtraControllerArgs cli.StringSlice
|
||||
Rootless bool
|
||||
StorageBackend string
|
||||
StorageEndpoint string
|
||||
StorageCAFile string
|
||||
StorageCertFile string
|
||||
StorageKeyFile string
|
||||
}
|
||||
|
||||
var ServerConfig Server
|
||||
|
@ -138,12 +142,36 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
|
|||
Usage: "(experimental) Run rootless",
|
||||
Destination: &ServerConfig.Rootless,
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "storage-backend",
|
||||
Usage: "Specify storage type etcd3 or kvsql",
|
||||
Destination: &ServerConfig.StorageBackend,
|
||||
EnvVar: "K3S_STORAGE_BACKEND",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "storage-endpoint",
|
||||
Usage: "Specify Mysql, Postgres, or Sqlite (default) data source name",
|
||||
Usage: "Specify etcd, Mysql, Postgres, or Sqlite (default) data source name",
|
||||
Destination: &ServerConfig.StorageEndpoint,
|
||||
EnvVar: "K3S_STORAGE_ENDPOINT",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "storage-cafile",
|
||||
Usage: "SSL Certificate Authority file used to secure storage backend communication",
|
||||
Destination: &ServerConfig.StorageCAFile,
|
||||
EnvVar: "K3S_STORAGE_CAFILE",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "storage-certfile",
|
||||
Usage: "SSL certification file used to secure storage backend communication",
|
||||
Destination: &ServerConfig.StorageCertFile,
|
||||
EnvVar: "K3S_STORAGE_CERTFILE",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "storage-keyfile",
|
||||
Usage: "SSL key file used to secure storage backend communication",
|
||||
Destination: &ServerConfig.StorageKeyFile,
|
||||
EnvVar: "K3S_STORAGE_KEYFILE",
|
||||
},
|
||||
NodeIPFlag,
|
||||
NodeNameFlag,
|
||||
DockerFlag,
|
||||
|
|
|
@ -109,6 +109,10 @@ func run(app *cli.Context, cfg *cmds.Server) error {
|
|||
serverConfig.ControlConfig.ExtraSchedulerAPIArgs = cfg.ExtraSchedulerArgs
|
||||
serverConfig.ControlConfig.ClusterDomain = cfg.ClusterDomain
|
||||
serverConfig.ControlConfig.StorageEndpoint = cfg.StorageEndpoint
|
||||
serverConfig.ControlConfig.StorageBackend = cfg.StorageBackend
|
||||
serverConfig.ControlConfig.StorageCAFile = cfg.StorageCAFile
|
||||
serverConfig.ControlConfig.StorageCertFile = cfg.StorageCertFile
|
||||
serverConfig.ControlConfig.StorageKeyFile = cfg.StorageKeyFile
|
||||
|
||||
_, serverConfig.ControlConfig.ClusterIPRange, err = net2.ParseCIDR(cfg.ClusterCIDR)
|
||||
if err != nil {
|
||||
|
|
|
@ -72,7 +72,11 @@ type Control struct {
|
|||
KubeConfigMode string
|
||||
DataDir string
|
||||
Skips []string
|
||||
StorageBackend string
|
||||
StorageEndpoint string
|
||||
StorageCAFile string
|
||||
StorageCertFile string
|
||||
StorageKeyFile string
|
||||
NoScheduler bool
|
||||
ExtraAPIArgs []string
|
||||
ExtraControllerArgs []string
|
||||
|
|
|
@ -146,6 +146,8 @@ func scheduler(cfg *config.Control, runtime *config.ControlRuntime) {
|
|||
|
||||
func apiServer(ctx context.Context, cfg *config.Control, runtime *config.ControlRuntime) (authenticator.Request, http.Handler, error) {
|
||||
argsMap := make(map[string]string)
|
||||
|
||||
setupStorageBackend(argsMap, cfg)
|
||||
if len(cfg.StorageEndpoint) > 0 {
|
||||
argsMap["etcd-servers"] = cfg.StorageEndpoint
|
||||
}
|
||||
|
@ -599,3 +601,24 @@ func kubeConfig(dest, url, cert, user, password string) error {
|
|||
|
||||
return kubeconfigTemplate.Execute(output, &data)
|
||||
}
|
||||
|
||||
func setupStorageBackend(argsMap map[string]string, cfg *config.Control) {
|
||||
// setup the storage backend
|
||||
if len(cfg.StorageBackend) > 0 {
|
||||
argsMap["storage-backend"] = cfg.StorageBackend
|
||||
}
|
||||
// specify the endpoints
|
||||
if len(cfg.StorageEndpoint) > 0 {
|
||||
argsMap["etcd-servers"] = cfg.StorageEndpoint
|
||||
}
|
||||
// storage backend tls configuration
|
||||
if len(cfg.StorageCAFile) > 0 {
|
||||
argsMap["etcd-cafile"] = cfg.StorageCAFile
|
||||
}
|
||||
if len(cfg.StorageCertFile) > 0 {
|
||||
argsMap["etcd-certfile"] = cfg.StorageCertFile
|
||||
}
|
||||
if len(cfg.StorageKeyFile) > 0 {
|
||||
argsMap["etcd-keyfile"] = cfg.StorageKeyFile
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue