Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose --agent-arg like --server-arg #96

Merged
merged 2 commits into from
Aug 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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