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

fix: allow IPv6 addresses for --ip and --server args #441

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os/exec"
"path/filepath"
"runtime"
"strconv"
"strings"

"github.com/alexellis/k3sup/pkg"
Expand Down Expand Up @@ -294,7 +295,7 @@ Provide the --local-path flag with --merge if a kubeconfig already exists in som
sshKey, _ := command.Flags().GetString("ssh-key")

sshKeyPath := expandPath(sshKey)
address := fmt.Sprintf("%s:%d", host, port)
address := net.JoinHostPort(host, strconv.Itoa(port))

sshOperator, sshOperatorDone, errored, err := connectOperator(user, address, sshKeyPath)
if errored {
Expand Down
9 changes: 5 additions & 4 deletions cmd/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"path"
"runtime"
"strconv"
"strings"

"errors"
Expand Down Expand Up @@ -198,7 +199,7 @@ func MakeJoin() *cobra.Command {
sshKeyPath := expandPath(sshKey)

if len(nodeToken) == 0 {
address := fmt.Sprintf("%s:%d", serverHost, serverPort)
address := net.JoinHostPort(host, strconv.Itoa(serverPort))

sshOperator, sshOperatorDone, errored, err := connectOperator(serverUser, address, sshKeyPath)
if errored {
Expand Down Expand Up @@ -312,7 +313,7 @@ func MakeJoin() *cobra.Command {
}

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)
address := net.JoinHostPort(host, strconv.Itoa(port))

var sshOperator *operator.SSHOperator
var initialSSHErr error
Expand Down Expand Up @@ -404,7 +405,7 @@ func setupAdditionalServer(serverHost, host string, port int, user, sshKeyPath,

func setupAgent(serverHost, host string, port int, user, sshKeyPath, joinToken, k3sExtraArgs, k3sVersion, k3sChannel string, printCommand bool, serverURL string) error {

address := fmt.Sprintf("%s:%d", host, port)
address := net.JoinHostPort(host, strconv.Itoa(port))

var sshOperator *operator.SSHOperator
var initialSSHErr error
Expand Down Expand Up @@ -505,7 +506,7 @@ func createVersionStr(k3sVersion, k3sChannel string) string {
func makeJoinExec(serverIP, joinToken, installStr, k3sExtraArgs string, serverAgent bool, serverURL, tlsSan string) string {

installEnvVar := []string{}
remoteURL := fmt.Sprintf("https://%s:6443", serverIP)
remoteURL := "https://" + net.JoinHostPort(serverIP, "6443")
if len(serverURL) > 0 {
remoteURL = serverURL
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/node-token.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net"
"os"
"path"
"strconv"
"strings"

"github.com/alexellis/k3sup/pkg"
Expand Down Expand Up @@ -101,7 +102,7 @@ server or agent to join the cluster.
dataDir, _ := command.Flags().GetString("server-data-dir")

sshKeyPath := expandPath(sshKey)
address := fmt.Sprintf("%s:%d", host, port)
address := net.JoinHostPort(host, strconv.Itoa(port))
if !local {
fmt.Fprintf(os.Stderr, "Remote: %s\n", address)
}
Expand Down