Skip to content

Commit

Permalink
Merge pull request #96 from misakwa/misakwa/agent-args
Browse files Browse the repository at this point in the history
Expose `--agent-arg` like `--server-arg`
  • Loading branch information
andyz-dev authored Aug 6, 2019
2 parents 33b79b1 + 29204d1 commit 460ff82
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func CreateCluster(c *cli.Context) error {
return err
}

k3AgentArgs := []string{}
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.
Expand All @@ -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 {
Expand All @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions cli/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down

0 comments on commit 460ff82

Please sign in to comment.