Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
17d8708c
Commit
17d8708c
authored
Jun 12, 2019
by
galal-hussein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add storage backend flags
parent
e82b62cb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
1 deletion
+60
-1
server.go
pkg/cli/cmds/server.go
+29
-1
server.go
pkg/cli/server/server.go
+4
-0
types.go
pkg/daemons/config/types.go
+4
-0
server.go
pkg/daemons/control/server.go
+23
-0
No files found.
pkg/cli/cmds/server.go
View file @
17d8708c
...
...
@@ -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
...
...
@@ -139,11 +143,35 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
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
,
...
...
pkg/cli/server/server.go
View file @
17d8708c
...
...
@@ -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
{
...
...
pkg/daemons/config/types.go
View file @
17d8708c
...
...
@@ -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
...
...
pkg/daemons/control/server.go
View file @
17d8708c
...
...
@@ -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
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment