Add agent-arg and pass through to container
This commit is contained in:
parent
33b79b1567
commit
4e52afd578
@ -105,6 +105,7 @@ func CreateCluster(c *cli.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
k3AgentArgs := make([]string, 0)
|
||||
k3sServerArgs := []string{"--https-listen-port", apiPort.Port}
|
||||
|
||||
// When the 'host' is not provided by --api-port, try to fill it using Docker Machine's IP address.
|
||||
@ -129,6 +130,10 @@ func CreateCluster(c *cli.Context) error {
|
||||
k3sServerArgs = append(k3sServerArgs, c.StringSlice("server-arg")...)
|
||||
}
|
||||
|
||||
if c.IsSet("agent-arg") {
|
||||
k3AgentArgs = append(k3AgentArgs, c.StringSlice("agent-arg")...)
|
||||
}
|
||||
|
||||
// new port map
|
||||
portmap, err := mapNodesToPortSpecs(c.StringSlice("publish"), GetAllContainerNames(c.String("name"), defaultServerCount, c.Int("workers")))
|
||||
if err != nil {
|
||||
@ -145,7 +150,7 @@ func CreateCluster(c *cli.Context) error {
|
||||
volumes = append(volumes, fmt.Sprintf("%s:/images", imageVolume.Name))
|
||||
|
||||
clusterSpec := &ClusterSpec{
|
||||
AgentArgs: []string{},
|
||||
AgentArgs: k3AgentArgs,
|
||||
APIPort: *apiPort,
|
||||
AutoRestart: c.Bool("auto-restart"),
|
||||
ClusterName: c.String("name"),
|
||||
|
@ -204,6 +204,7 @@ func createWorker(spec *ClusterSpec, postfix int) (string, error) {
|
||||
Hostname: containerName,
|
||||
Image: spec.Image,
|
||||
Env: env,
|
||||
Cmd: append([]string{"agent"}, spec.AgentArgs...),
|
||||
Labels: containerLabels,
|
||||
ExposedPorts: workerPublishedPorts.ExposedPorts,
|
||||
}
|
||||
|
4
main.go
4
main.go
@ -116,6 +116,10 @@ func main() {
|
||||
Name: "server-arg, x",
|
||||
Usage: "Pass an additional argument to k3s server (new flag per argument)",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "agent-arg",
|
||||
Usage: "Pass an additional argument to k3s agent (new flag per argument)",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "env, e",
|
||||
Usage: "Pass an additional environment variable (new flag per variable)",
|
||||
|
Loading…
Reference in New Issue
Block a user