- {generateAddNodeCommand.command.map((command, index) => (
+ {generateAddNodeCommand.commands.map((command, index) => (
{addNodesCommandInstructions[index] && (
From f3882281852a2539937796b7382939e53c975812 Mon Sep 17 00:00:00 2001
From: Ethan Mosbaugh
Date: Mon, 28 Apr 2025 13:24:17 -0700
Subject: [PATCH 4/7] get join-command
---
cmd/kots/cli/get-joincommand.go | 6 +++---
cmd/kots/cli/get-joincommand_test.go | 24 ++++++++++++++++--------
cmd/kots/cli/get.go | 10 ----------
3 files changed, 19 insertions(+), 21 deletions(-)
diff --git a/cmd/kots/cli/get-joincommand.go b/cmd/kots/cli/get-joincommand.go
index 554739e5fe..b84f02a4e8 100644
--- a/cmd/kots/cli/get-joincommand.go
+++ b/cmd/kots/cli/get-joincommand.go
@@ -49,7 +49,7 @@ func GetJoinCmd() *cobra.Command {
format := v.GetString("output")
if format == "string" || format == "" {
- fmt.Println(strings.Join(joinCmd, " "))
+ fmt.Println(strings.Join(joinCmd, " && \n "))
return nil
} else if format == "json" {
type joinCommandResponse struct {
@@ -58,7 +58,7 @@ func GetJoinCmd() *cobra.Command {
joinCmdResponse := joinCommandResponse{
Command: joinCmd,
}
- b, err := json.Marshal(joinCmdResponse)
+ b, err := json.MarshalIndent(joinCmdResponse, "", " ")
if err != nil {
return fmt.Errorf("failed to marshal join command: %w", err)
}
@@ -117,7 +117,7 @@ func getJoinCommandCmd(ctx context.Context, clientset kubernetes.Interface, name
return nil, fmt.Errorf("failed to get join command: %w", err)
}
- return joinCommand.Command, nil
+ return joinCommand.Commands, nil
}
// determine the embedded cluster roles list from /api/v1/embedded-cluster/roles
diff --git a/cmd/kots/cli/get-joincommand_test.go b/cmd/kots/cli/get-joincommand_test.go
index 579cf78dc1..53a92dc424 100644
--- a/cmd/kots/cli/get-joincommand_test.go
+++ b/cmd/kots/cli/get-joincommand_test.go
@@ -16,7 +16,7 @@ import (
"k8s.io/client-go/kubernetes/fake"
)
-func TestGetJoinCommand(t *testing.T) {
+func Test_getJoinCommandCmd(t *testing.T) {
tests := []struct {
name string
service *corev1.Service
@@ -59,7 +59,7 @@ func TestGetJoinCommand(t *testing.T) {
"controllerRoleName": "test-controller-role-name",
}
w.Header().Set("Content-Type", "application/json")
- json.NewEncoder(w).Encode(response)
+ _ = json.NewEncoder(w).Encode(response)
case "POST":
require.Equal(t, "/api/v1/embedded-cluster/generate-node-join-command", r.URL.Path)
require.Equal(t, "test-auth-token", r.Header.Get("Authorization"))
@@ -73,13 +73,21 @@ func TestGetJoinCommand(t *testing.T) {
require.Equal(t, []string{"test-controller-role-name"}, requestBody.Roles)
response := map[string][]string{
- "command": {"embedded-cluster", "join", "--token", "test-token"},
+ "commands": {
+ "curl -k https://172.17.0.2:30000/api/v1/embedded-cluster/binary -o embedded-cluster.tar.gz",
+ "tar -xzf embedded-cluster.tar.gz",
+ "sudo ./embedded-cluster join 172.17.0.2:30000 7nPgRfWVZ3QIRWOnzsITEpLt",
+ },
}
w.Header().Set("Content-Type", "application/json")
- json.NewEncoder(w).Encode(response)
+ _ = json.NewEncoder(w).Encode(response)
}
},
- expectedCmd: []string{"embedded-cluster", "join", "--token", "test-token"},
+ expectedCmd: []string{
+ "curl -k https://172.17.0.2:30000/api/v1/embedded-cluster/binary -o embedded-cluster.tar.gz",
+ "tar -xzf embedded-cluster.tar.gz",
+ "sudo ./embedded-cluster join 172.17.0.2:30000 7nPgRfWVZ3QIRWOnzsITEpLt",
+ },
},
{
name: "missing service",
@@ -115,7 +123,7 @@ func TestGetJoinCommand(t *testing.T) {
"error": "internal server error",
}
w.Header().Set("Content-Type", "application/json")
- json.NewEncoder(w).Encode(response)
+ _ = json.NewEncoder(w).Encode(response)
},
expectedError: "failed to get roles: unexpected status code: 500",
},
@@ -154,14 +162,14 @@ func TestGetJoinCommand(t *testing.T) {
"controllerRoleName": "test-controller-role-name",
}
w.Header().Set("Content-Type", "application/json")
- json.NewEncoder(w).Encode(response)
+ _ = json.NewEncoder(w).Encode(response)
case "POST":
w.WriteHeader(http.StatusInternalServerError)
response := map[string]string{
"error": "internal server error",
}
w.Header().Set("Content-Type", "application/json")
- json.NewEncoder(w).Encode(response)
+ _ = json.NewEncoder(w).Encode(response)
}
},
expectedError: "failed to get join command: unexpected status code: 500",
diff --git a/cmd/kots/cli/get.go b/cmd/kots/cli/get.go
index 2d21831c87..5d9adc2426 100644
--- a/cmd/kots/cli/get.go
+++ b/cmd/kots/cli/get.go
@@ -1,8 +1,6 @@
package cli
import (
- "os"
-
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
@@ -19,14 +17,6 @@ kubectl kots get apps`,
PreRun: func(cmd *cobra.Command, args []string) {
viper.BindPFlags(cmd.Flags())
},
- RunE: func(cmd *cobra.Command, args []string) error {
- if len(args) == 0 {
- cmd.Help()
- os.Exit(1)
- }
-
- return nil
- },
}
cmd.AddCommand(GetAppsCmd())
From 5e18635e12a2b8d2b8e31fd68dd7264428f06dc1 Mon Sep 17 00:00:00 2001
From: Ethan Mosbaugh
Date: Mon, 28 Apr 2025 13:25:56 -0700
Subject: [PATCH 5/7] get join-command
---
cmd/kots/cli/get-joincommand.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/cmd/kots/cli/get-joincommand.go b/cmd/kots/cli/get-joincommand.go
index b84f02a4e8..0a731646d6 100644
--- a/cmd/kots/cli/get-joincommand.go
+++ b/cmd/kots/cli/get-joincommand.go
@@ -53,10 +53,10 @@ func GetJoinCmd() *cobra.Command {
return nil
} else if format == "json" {
type joinCommandResponse struct {
- Command []string `json:"command"`
+ Commands []string `json:"commands"`
}
joinCmdResponse := joinCommandResponse{
- Command: joinCmd,
+ Commands: joinCmd,
}
b, err := json.MarshalIndent(joinCmdResponse, "", " ")
if err != nil {
From 08c014c62d403a84d9eee7423eb041d56d4369f0 Mon Sep 17 00:00:00 2001
From: Ethan Mosbaugh
Date: Mon, 28 Apr 2025 13:39:17 -0700
Subject: [PATCH 6/7] step numbers
---
web/src/components/apps/EmbeddedClusterManagement.tsx | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/web/src/components/apps/EmbeddedClusterManagement.tsx b/web/src/components/apps/EmbeddedClusterManagement.tsx
index f1ed7c97c4..b609878095 100644
--- a/web/src/components/apps/EmbeddedClusterManagement.tsx
+++ b/web/src/components/apps/EmbeddedClusterManagement.tsx
@@ -516,7 +516,8 @@ const EmbeddedClusterManagement = ({
{generateAddNodeCommand.commands.map((command, index) => (
{addNodesCommandInstructions[index] && (
-
+
+ {index + 1}
{addNodesCommandInstructions[index]}
)}
From bb49634f71d7cf62101cc2d0217b72c55c910ed9 Mon Sep 17 00:00:00 2001
From: Ethan Mosbaugh
Date: Mon, 28 Apr 2025 14:15:25 -0700
Subject: [PATCH 7/7] feedback
---
cmd/kots/cli/get-joincommand.go | 2 +-
web/src/components/apps/EmbeddedClusterManagement.tsx | 6 +++---
web/src/components/modals/AddANodeModal.tsx | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/cmd/kots/cli/get-joincommand.go b/cmd/kots/cli/get-joincommand.go
index 0a731646d6..9af630e7e2 100644
--- a/cmd/kots/cli/get-joincommand.go
+++ b/cmd/kots/cli/get-joincommand.go
@@ -49,7 +49,7 @@ func GetJoinCmd() *cobra.Command {
format := v.GetString("output")
if format == "string" || format == "" {
- fmt.Println(strings.Join(joinCmd, " && \n "))
+ fmt.Println(strings.Join(joinCmd, " && \\\n "))
return nil
} else if format == "json" {
type joinCommandResponse struct {
diff --git a/web/src/components/apps/EmbeddedClusterManagement.tsx b/web/src/components/apps/EmbeddedClusterManagement.tsx
index b609878095..39c34b978a 100644
--- a/web/src/components/apps/EmbeddedClusterManagement.tsx
+++ b/web/src/components/apps/EmbeddedClusterManagement.tsx
@@ -431,7 +431,7 @@ const EmbeddedClusterManagement = ({
{rolesData?.roles &&
rolesData.roles.length > 1 &&
"Select one or more roles to assign to the new node."}{" "}
- Copy the join commands and run them on the machine you'd like to join to
+ Copy the commands and run them on the machine you'd like to join to
the cluster.
@@ -439,8 +439,8 @@ const EmbeddedClusterManagement = ({
};
const addNodesCommandInstructions = [
- "Download the installation assets",
- "Extract the installation assets",
+ "Download the binary on the new node",
+ "Extract the binary",
"Join the node to the cluster",
];
diff --git a/web/src/components/modals/AddANodeModal.tsx b/web/src/components/modals/AddANodeModal.tsx
index 075dfc6a67..883fa23ca8 100644
--- a/web/src/components/modals/AddANodeModal.tsx
+++ b/web/src/components/modals/AddANodeModal.tsx
@@ -31,7 +31,7 @@ const AddANodeModal = ({
{rolesData?.roles &&
rolesData.roles.length > 1 &&
"Select one or more roles to assign to the new node. "}
- Copy the join commands and run them on the machine you'd like to join to
+ Copy the commands and run them on the machine you'd like to join to
the cluster.
{children}