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

Add --no-extras flag to join command #425

Merged
merged 1 commit into from
Dec 29, 2023
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
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
Loading