Skip to content

Commit

Permalink
Add --no-extra flag to join command
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
rgee0 authored and alexellis committed Dec 29, 2023
1 parent cca4497 commit d952d6d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,23 @@ paprika-gregory Ready master 8m27s v1.19.2-k3s
cave-sensor Ready master 27m v1.19.2-k3s
```
If you used `--no-extras` on the initial installation you will also need to provide it on each join:
```sh
export USER=root
export SERVER_IP=192.168.0.100
export NEXT_SERVER_IP=192.168.0.101
k3sup join \
--ip $NEXT_SERVER_IP \
--user $USER \
--server-user $USER \
--server-ip $SERVER_IP \
--server \
--no-extras \
--k3s-version v1.19.1+k3s1
```
### 👨‍💻 Micro-tutorial for Raspberry Pi (2, 3, or 4) 🥧
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.
Expand Down
22 changes: 19 additions & 3 deletions cmd/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func MakeJoin() *cobra.Command {
command.Flags().Bool("sudo", true, "Use sudo for installation. e.g. set to false when using the root user and no sudo is available.")

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

if server {

tlsSan, _ := command.Flags().GetString("tls-san")
noExtras, _ := command.Flags().GetBool("no-extras")

err = setupAdditionalServer(serverHost, host, port, user, sshKeyPath, nodeToken, k3sExtraArgs, k3sVersion, k3sChannel, tlsSan, printCommand, serverURL)
err = setupAdditionalServer(serverHost, host, port, user, sshKeyPath, nodeToken, k3sExtraArgs, k3sVersion, k3sChannel, tlsSan, printCommand, serverURL, noExtras)
} else {
err = setupAgent(serverHost, host, port, user, sshKeyPath, nodeToken, k3sExtraArgs, k3sVersion, k3sChannel, printCommand, serverURL)
}
Expand Down Expand Up @@ -282,13 +285,21 @@ func MakeJoin() *cobra.Command {
return err
}

if len(tlsSan) > 0 {
noExtras, err := command.Flags().GetBool("no-extras")
if err != nil {
return err
}

if len(tlsSan) > 0 || noExtras {
server, err := command.Flags().GetBool("server")
if err != nil {
return err
}

if !server {
if noExtras {
return fmt.Errorf("--no-extras can only be used with --server")
}
return fmt.Errorf("--tls-san can only be used with --server")
}

Expand All @@ -300,7 +311,7 @@ func MakeJoin() *cobra.Command {
return command
}

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

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

defer sshOperator.Close()

if noExtras {
k3sExtraArgs += " --disable servicelb"
k3sExtraArgs += " --disable traefik"
}

installk3sExec := makeJoinExec(
serverHost,
strings.TrimSpace(joinToken),
Expand Down

0 comments on commit d952d6d

Please sign in to comment.