Skip to content

Commit d952d6d

Browse files
rgee0alexellis
authored andcommitted
Add --no-extra flag to join command
It was found that when joining servers to a cluster any additional servers would not honour the `--no-extras` flag used with the install command. It is necessary, therefore, for the flag to be added to `join` and only be applied in situations where `--server` has been provided. Signed-off-by: Richard Gee <richard@technologee.co.uk>
1 parent cca4497 commit d952d6d

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,23 @@ paprika-gregory Ready master 8m27s v1.19.2-k3s
538538
cave-sensor Ready master 27m v1.19.2-k3s
539539
```
540540
541+
If you used `--no-extras` on the initial installation you will also need to provide it on each join:
542+
543+
```sh
544+
export USER=root
545+
export SERVER_IP=192.168.0.100
546+
export NEXT_SERVER_IP=192.168.0.101
547+
548+
k3sup join \
549+
--ip $NEXT_SERVER_IP \
550+
--user $USER \
551+
--server-user $USER \
552+
--server-ip $SERVER_IP \
553+
--server \
554+
--no-extras \
555+
--k3s-version v1.19.1+k3s1
556+
```
557+
541558
### 👨‍💻 Micro-tutorial for Raspberry Pi (2, 3, or 4) 🥧
542559
543560
In a few moments you will have Kubernetes up and running on your Raspberry Pi 2, 3 or 4. Stand by for the fastest possible install. At the end you will have a KUBECONFIG file on your local computer that you can use to access your cluster remotely.

cmd/join.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ func MakeJoin() *cobra.Command {
6565
command.Flags().Bool("sudo", true, "Use sudo for installation. e.g. set to false when using the root user and no sudo is available.")
6666

6767
command.Flags().Bool("server", false, "Join the cluster as a server rather than as an agent for the embedded etcd mode")
68+
command.Flags().Bool("no-extras", false, `Disable "servicelb" and "traefik", when using --server flag`)
6869
command.Flags().Bool("print-command", false, "Print a command that you can use with SSH to manually recover from an error")
6970
command.Flags().String("node-token-path", "", "file containing --node-token")
7071
command.Flags().String("node-token", "", "prefetched token used by nodes to join the cluster")
@@ -236,9 +237,11 @@ func MakeJoin() *cobra.Command {
236237
}
237238

238239
if server {
240+
239241
tlsSan, _ := command.Flags().GetString("tls-san")
242+
noExtras, _ := command.Flags().GetBool("no-extras")
240243

241-
err = setupAdditionalServer(serverHost, host, port, user, sshKeyPath, nodeToken, k3sExtraArgs, k3sVersion, k3sChannel, tlsSan, printCommand, serverURL)
244+
err = setupAdditionalServer(serverHost, host, port, user, sshKeyPath, nodeToken, k3sExtraArgs, k3sVersion, k3sChannel, tlsSan, printCommand, serverURL, noExtras)
242245
} else {
243246
err = setupAgent(serverHost, host, port, user, sshKeyPath, nodeToken, k3sExtraArgs, k3sVersion, k3sChannel, printCommand, serverURL)
244247
}
@@ -282,13 +285,21 @@ func MakeJoin() *cobra.Command {
282285
return err
283286
}
284287

285-
if len(tlsSan) > 0 {
288+
noExtras, err := command.Flags().GetBool("no-extras")
289+
if err != nil {
290+
return err
291+
}
292+
293+
if len(tlsSan) > 0 || noExtras {
286294
server, err := command.Flags().GetBool("server")
287295
if err != nil {
288296
return err
289297
}
290298

291299
if !server {
300+
if noExtras {
301+
return fmt.Errorf("--no-extras can only be used with --server")
302+
}
292303
return fmt.Errorf("--tls-san can only be used with --server")
293304
}
294305

@@ -300,7 +311,7 @@ func MakeJoin() *cobra.Command {
300311
return command
301312
}
302313

303-
func setupAdditionalServer(serverHost, host string, port int, user, sshKeyPath, joinToken, k3sExtraArgs, k3sVersion, k3sChannel, tlsSAN string, printCommand bool, serverURL string) error {
314+
func setupAdditionalServer(serverHost, host string, port int, user, sshKeyPath, joinToken, k3sExtraArgs, k3sVersion, k3sChannel, tlsSAN string, printCommand bool, serverURL string, noExtras bool) error {
304315
address := fmt.Sprintf("%s:%d", host, port)
305316

306317
var sshOperator *operator.SSHOperator
@@ -355,6 +366,11 @@ func setupAdditionalServer(serverHost, host string, port int, user, sshKeyPath,
355366

356367
defer sshOperator.Close()
357368

369+
if noExtras {
370+
k3sExtraArgs += " --disable servicelb"
371+
k3sExtraArgs += " --disable traefik"
372+
}
373+
358374
installk3sExec := makeJoinExec(
359375
serverHost,
360376
strings.TrimSpace(joinToken),

0 commit comments

Comments
 (0)