Skip to content

Commit

Permalink
Add --server-k3s-extra-args for disabling traefik etc
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Oct 27, 2023
1 parent bb4baf4 commit 0903a7d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ k3sup plan \
devices.json \
--user ubuntu \
--servers 3 \
--server-k3s-extra-args "--disable traefik"
--background > bootstrap.sh
```

Expand All @@ -338,7 +339,7 @@ chmod +x bootstrap.sh

Watch a demo with dozens of Firecracker VMs: [Testing Kubernetes at Scale with bare-metal](https://youtu.be/o4UxRw-Cc8c)

The initial version of `k3sup plan` has a reduced set of flags such as `--k3s-extra-args`, but contributions are welcomed from users and sponsors.
The initial version of `k3sup plan` has a reduced set of flags. Flags such as `--k3s-version` and `--datastore` are not available, but feel free to propose an issue with what you need.

### Create a multi-master (HA) setup with external SQL

Expand Down
30 changes: 24 additions & 6 deletions cmd/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Input file format, in JSON:

command.Flags().String("ssh-key", "", "Path to the private key for SSH login")
command.Flags().String("tls-san", "", "SAN for TLS certificates, can be a comma-separated list")
command.Flags().String("server-k3s-extra-args", "", "Extra arguments to be passed into the k3s server")
command.Flags().String("agent-k3s-extra-args", "", "Extra arguments to be passed into the k3s agent")

// Background
command.Flags().Bool("background", false, "Run the installation in the background for all agents/nodes after the first server is up")
Expand All @@ -70,6 +72,9 @@ Input file format, in JSON:
return err
}

serverK3sExtraArgs, _ := cmd.Flags().GetString("server-k3s-extra-args")
agentK3sExtraArgs, _ := cmd.Flags().GetString("agent-k3s-extra-args")

servers, _ := cmd.Flags().GetInt("servers")
kubeconfig, _ := cmd.Flags().GetString("local-path")
contextName, _ := cmd.Flags().GetString("context")
Expand All @@ -92,6 +97,17 @@ Input file format, in JSON:
var primaryServer Host
script := "#!/bin/sh\n\n"

serverExtraArgsSt := ""
if len(serverK3sExtraArgs) > 0 {
serverExtraArgsSt = fmt.Sprintf(` \
--k3s-extra-args "%s"`, serverK3sExtraArgs)
}
agentExtraArgsSt := ""
if len(agentK3sExtraArgs) > 0 {
agentExtraArgsSt = fmt.Sprintf(` \
--k3s-extra-args "%s"`, agentK3sExtraArgs)
}

for i, host := range hosts {
if serversAdded == 0 {

Expand All @@ -102,12 +118,14 @@ Input file format, in JSON:
--user %s \
--cluster \
--local-path %s \
--context %s%s
--context %s%s%s
`,
host.IP,
user,
kubeconfig,
contextName, tlsSanStr)
contextName,
tlsSanStr,
serverExtraArgsSt)

script += fmt.Sprintf(`
echo "Fetching the server's node-token into memory"
Expand All @@ -125,8 +143,8 @@ export NODE_TOKEN=$(k3sup node-token --host %s --user %s)
--server-host %s \
--server \
--node-token "$NODE_TOKEN" \
--user %s%s%s
`, host.IP, primaryServer.IP, user, tlsSanStr, bgStr)
--user %s%s%s%s
`, host.IP, primaryServer.IP, user, tlsSanStr, serverExtraArgsSt, bgStr)

serversAdded++
} else {
Expand All @@ -136,8 +154,8 @@ export NODE_TOKEN=$(k3sup node-token --host %s --user %s)
--host %s \
--server-host %s \
--node-token "$NODE_TOKEN" \
--user %s%s
`, host.IP, primaryServer.IP, user, bgStr)
--user %s%s%s
`, host.IP, primaryServer.IP, user, agentExtraArgsSt, bgStr)
}

if nodeLimit > 0 && i+1 >= nodeLimit {
Expand Down

0 comments on commit 0903a7d

Please sign in to comment.