From afe2780cafb19dc01caf6cdc0fcf23cff98c0033 Mon Sep 17 00:00:00 2001 From: Sarthak Jain Date: Wed, 27 Jul 2022 09:39:00 +0530 Subject: [PATCH] Updated commands (#15) * Update create agent to connect chaos-delegate and get agents to get chaos-delegates Signed-off-by: Sarthak Jain * Fixed typos Signed-off-by: Sarthak Jain --- Usage.md | 64 ++++++++++++++-------------- Usage_interactive.md | 34 +++++++-------- pkg/agent/ops.go | 8 ++-- pkg/apis/agent.go | 4 +- pkg/cmd/{create => connect}/agent.go | 56 ++++++++++++------------ pkg/cmd/connect/connect.go | 36 ++++++++++++++++ pkg/cmd/create/create.go | 6 --- pkg/cmd/get/agents.go | 4 +- pkg/cmd/get/get.go | 2 +- pkg/cmd/root/root.go | 4 +- pkg/cmd/upgrade/agent.go | 8 ++-- pkg/cmd/upgrade/upgrade.go | 2 +- pkg/k8s/operations.go | 2 +- 13 files changed, 131 insertions(+), 99 deletions(-) rename pkg/cmd/{create => connect}/agent.go (81%) create mode 100644 pkg/cmd/connect/connect.go diff --git a/Usage.md b/Usage.md index 3f3b261..1150d07 100644 --- a/Usage.md +++ b/Usage.md @@ -8,8 +8,8 @@ chaosctl [command] [TYPE] [flags] ``` -- Command: refers to what you do want to perform (create, get and config) -- Type: refers to the feature type you are performing a command against (agent, project etc.) +- Command: refers to what you do want to perform (connect, create, get and config) +- Type: refers to the feature type you are performing a command against (chaos-delegate, project etc.) - Flags: It takes some additional information for resource operations. For example, `--installation-mode` allows you to specify an installation mode. chaosctl is using the `.chaosconfig` config file to manage multiple accounts @@ -19,21 +19,21 @@ chaosctl is using the `.chaosconfig` config file to manage multiple accounts chaosctl supports both interactive and non-interactive(flag based) modes. -> Only `chaosctl create agent` command needs --non-interactive flag, other commands don't need this flag to be in non-interactive mode. If mandatory flags aren't passed, then chaosctl takes input in an interactive mode. +> Only `chaosctl connect chaos-delegate` command needs --non-interactive flag, other commands don't need this flag to be in non-interactive mode. If mandatory flags aren't passed, then chaosctl takes input in an interactive mode. ### Installation modes -chaosctl can install an agent in two different modes. +chaosctl can install a chaos delegate in two different modes. -- cluster mode: With this mode, the agent can run the chaos in any namespace. It installs appropriate cluster roles and cluster role bindings to achieve this mode. It can be enabled by passing a flag `--installation-mode=cluster` +- cluster mode: With this mode, the chaos delegate can run the chaos in any namespace. It installs appropriate cluster roles and cluster role bindings to achieve this mode. It can be enabled by passing a flag `--installation-mode=cluster` -- namespace mode: With this mode, the agent can run the chaos in its namespace. It installs appropriate roles and role bindings to achieve this mode. It can be enabled by passing a flag `--installation-mode=namespace` +- namespace mode: With this mode, the chaos delegate can run the chaos in its namespace. It installs appropriate roles and role bindings to achieve this mode. It can be enabled by passing a flag `--installation-mode=namespace` -Note: With namespace mode, the user needs to create the namespace to install the agent and user must have the admin privileges to setup [CRDs](https://github.com/chaosnative/hce-charts/blob/main/k8s-manifests/ci/hce-crds.yaml) as a prerequisite. +Note: With namespace mode, the user needs to create the namespace to install the chaos delegate and user must have the admin privileges to setup [CRDs](https://github.com/chaosnative/hce-charts/blob/main/k8s-manifests/ci/hce-crds.yaml) as a prerequisite. #### Prerequisite steps(For namespace mode) -- Create namespace to install the agnet +- Create namespace to install the chaos delegate ```shell kubectl create ns @@ -45,7 +45,7 @@ kubectl create ns kubectl apply -f https://raw.githubusercontent.com/litmuschaos/litmus/master/litmus-portal/litmus-portal-crds.yml ``` -### Minimal steps to create an agent +### Minimal steps to connect a chaos delegate - To setup an account with chaosctl @@ -53,23 +53,23 @@ kubectl apply -f https://raw.githubusercontent.com/litmuschaos/litmus/master/lit chaosctl config set-account --endpoint="" --access_id="" --access_key="" ``` -- To create an agent without a project - > Note: If the user doesn't have any project, it will create a random project and add the agent in that random project. +- To connect a chaos delegate without a project + > Note: If the user doesn't have any project, it will create a random project and add the chaos delegate in that random project. ```shell -chaosctl create agent --agent-name="" --non-interactive +chaosctl connect chaos-delegate --name="" --non-interactive ``` ### Or, -- To create an agent with an existing project +- To connect a chaos delegate with an existing project > Note: To get `project-id`. Apply `chaosctl get projects` ```shell -chaosctl create agent --agent-name="" --project-id="" --non-interactive +chaosctl connect chaos-delegate --name="" --project-id="" --non-interactive ``` -### Flags for `create agent` command +### Flags for `connect chaos-delegate` command @@ -78,34 +78,34 @@ chaosctl create agent --agent-name="" --project-id="" --non-interactive - + - + - + - + - + - + - + - + - + @@ -117,13 +117,13 @@ chaosctl create agent --agent-name="" --project-id="" --non-interactive - + - @@ -153,7 +153,7 @@ chaosctl create agent --agent-name="" --project-id="" --non-interactive - + @@ -229,18 +229,18 @@ PROJECT ID PROJECT NAME CREATEDAT 7a4a259a-1ae5-4204-ae83-89a8838eaec3 DevOps Project 2021-07-21 14:39:14 +0530 IST ``` -- To get an overview of the agents available within a project, issue the following command. +- To get an overview of the chaos delegates available within a project, issue the following command. ```shell -chaosctl get agents --project-id="" +chaosctl get chaos-delegates --project-id="" ``` **Output:** ``` -AGENTID AGENTNAME STATUS -55ecc7f2-2754-43aa-8e12-6903e4c6183a agent-1 ACTIVE -13dsf3d1-5324-54af-4g23-5331g5v2364f agent-2 INACTIVE +CHAOS DELEGATE ID CHAOS DELEGATE NAME STATUS +55ecc7f2-2754-43aa-8e12-6903e4c6183a chaos-delegate-1 ACTIVE +13dsf3d1-5324-54af-4g23-5331g5v2364f chaos-delegate-2 INACTIVE ``` For more information related to flags, Use `chaosctl --help`. diff --git a/Usage_interactive.md b/Usage_interactive.md index 1b057df..e1bf650 100644 --- a/Usage_interactive.md +++ b/Usage_interactive.md @@ -8,7 +8,7 @@ chaosctl [command] [TYPE] [flags] ``` -- Command: refers to what you do want to perform (create, get and config) +- Command: refers to what you do want to perform (connect, create, get and config) - Type: refers to the feature type you are performing a command against (chaos-delegate, project etc.) - Flags: It takes some additional information for resource operations. For example, `--installation-mode` allows you to specify an installation mode. @@ -19,9 +19,9 @@ chaosctl is using the `.chaosconfig` config file to manage multiple accounts chaosctl supports both interactive and non-interactive(flag based) modes. -> Only `chaosctl create agent` command needs --non-interactive flag, other commands don't need this flag to be in non-interactive mode. If mandatory flags aren't passed, then chaosctl takes input in an interactive mode. +> Only `chaosctl connect chaos-delegate` command needs --non-interactive flag, other commands don't need this flag to be in non-interactive mode. If mandatory flags aren't passed, then chaosctl takes input in an interactive mode. -### Steps to connect to an chaos delegate +### Steps to connect to a chaos delegate - To setup an account with chaosctl @@ -29,7 +29,7 @@ chaosctl supports both interactive and non-interactive(flag based) modes. chaosctl config set-account ``` -Next, you need to enter CLC/CLE details to login into your account. Fields to be filled in: +Next, you need to enter Harness Chaos Engineering Cloud/Harness Chaos Engineering Enterprise details to login into your account. Fields to be filled in: **What's the product name:** Select the product name . @@ -40,8 +40,8 @@ Next, you need to enter CLC/CLE details to login into your account. Fields to be ``` ? What's the product name?: - ▸ ChaosNative Cloud - ChaosNative Enterprise + ▸ Harness Chaos Engineering Cloud + Harness Chaos Engineering Enterprise What's the AccessID?: Raj60163RjxQE What's the AccessKey?: *************** @@ -49,10 +49,10 @@ What's the AccessKey?: *************** account.accessID/admin configured ``` -- To connect an chaos delegate in a cluster mode +- To connect a chaos delegate in a cluster mode ```shell -chaosctl create agent +chaosctl connect chaos-delegate ``` There will be a list of existing projects displayed on the terminal. Select the desired project by entering the sequence number indicated against it. @@ -64,7 +64,7 @@ There will be a list of existing projects displayed on the terminal. Select the Next, select the installation mode based on your requirement by entering the sequence number indicated against it. -It can install an chaos delegate in two different modes. +It can install a chaos delegate in two different modes. - cluster mode: With this mode, the chaos delegate can run the chaos in any namespace. It installs appropriate cluster roles and cluster role bindings to achieve this mode. @@ -92,11 +92,11 @@ Fields to be filled in
- + - + @@ -230,8 +230,8 @@ CURRENT ENDPOINT ACCESSID EXPIRESIN chaosctl config use-account ? What's the product name?: - ▸ ChaosNative Cloud - ChaosNative Enterprise + ▸ Harness Chaos Engineering Cloud + Harness Chaos Engineering Enterprise What's the AccessID?: Raj60163RjxQE ``` @@ -261,7 +261,7 @@ PROJECT ID PROJECT NAME CREATEDAT - To get an overview of the chaos delegates available within a project, issue the following command. ```shell -chaosctl get agents +chaosctl get chaos-delegates Enter the Project ID: 50addd40-8767-448c-a91a-5071543a2d8e ``` @@ -269,9 +269,9 @@ Enter the Project ID: 50addd40-8767-448c-a91a-5071543a2d8e **Output:** ``` -AGENTID AGENTNAME STATUS -55ecc7f2-2754-43aa-8e12-6903e4c6183a agent-1 ACTIVE -13dsf3d1-5324-54af-4g23-5331g5v2364f agent-2 INACTIVE +CHAOS DELEGATE ID CHAOS DELEGATE NAME STATUS +55ecc7f2-2754-43aa-8e12-6903e4c6183a chaos-delegate-1 ACTIVE +13dsf3d1-5324-54af-4g23-5331g5v2364f chaos-delegate-2 INACTIVE ``` For more information related to flags, Use `chaosctl --help`. diff --git a/pkg/agent/ops.go b/pkg/agent/ops.go index ad70d8f..538b0f8 100644 --- a/pkg/agent/ops.go +++ b/pkg/agent/ops.go @@ -27,7 +27,7 @@ import ( "github.com/manifoldco/promptui" ) -// GetProject display list of projects and returns the project id based on input +// GetProjectID display list of projects and returns the project id based on input func GetProjectID(u apis.ProjectDetails) string { var projectNames []string for _, v := range u.Data.Projects { @@ -49,7 +49,7 @@ func GetProjectID(u apis.ProjectDetails) string { return u.Data.Projects[counter].ID } -// GetMode gets mode of chaos delegate installation as input +// GetModeType gets mode of chaos delegate installation as input func GetModeType() string { prompt := promptui.Select{ Label: "What's the installation mode?", @@ -80,11 +80,11 @@ func GetAgentDetails(mode string, pid string, c types.Credentials, kubeconfig *s ) // Get chaos delegate name as input utils.White_B.Println("\nEnter the details of the chaos delegate") - // Label for goto statement in case of invalid agent name + // Label for goto statement in case of invalid chaos delegate name AGENT_NAME: prompt := promptui.Prompt{ - Label: "What's the Chaos Delegate Name?", + Label: "What's the chaos delegate name?", } newAgent.AgentName, err = prompt.Run() diff --git a/pkg/apis/agent.go b/pkg/apis/agent.go index 2a0f8cb..78a6d55 100644 --- a/pkg/apis/agent.go +++ b/pkg/apis/agent.go @@ -124,14 +124,14 @@ func ConnectAgent(agent types.Agent, cred types.Credentials) (AgentConnectionDat bodyBytes, err := ioutil.ReadAll(resp.Body) defer resp.Body.Close() if err != nil { - return AgentConnectionData{}, errors.New("Error in registering Chaos Delegate: " + err.Error()) + return AgentConnectionData{}, errors.New("Error in registering chaos delegate: " + err.Error()) } if resp.StatusCode == http.StatusOK { var connectAgent AgentConnectionData err = json.Unmarshal(bodyBytes, &connectAgent) if err != nil { - return AgentConnectionData{}, errors.New("Error in registering Chaos Delegate: " + err.Error()) + return AgentConnectionData{}, errors.New("Error in registering chaos delegate: " + err.Error()) } if len(connectAgent.Errors) > 0 { diff --git a/pkg/cmd/create/agent.go b/pkg/cmd/connect/agent.go similarity index 81% rename from pkg/cmd/create/agent.go rename to pkg/cmd/connect/agent.go index cf4b027..22f4e32 100644 --- a/pkg/cmd/create/agent.go +++ b/pkg/cmd/connect/agent.go @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -package create +package connect import ( "encoding/json" @@ -29,16 +29,16 @@ import ( "github.com/spf13/cobra" ) -// agentCmd represents the agent command +// agentCmd represents the chaos delegate command var agentCmd = &cobra.Command{ - Use: "agent", - Short: `Create an external Chaos Delegate. + Use: "chaos-delegate", + Short: `connect an external chaos delegate. Example(s): - #create an agent - chaosctl create agent --agent-name="new-agent" --non-interactive + #connect a chaos delegate + chaosctl connect chaos-delegate --name="new-chaos-delegate" --non-interactive - #create an agent within a project - chaosctl create agent --agent-name="new-agent" --project-id="d861b650-1549-4574-b2ba-ab754058dd04" --non-interactive + #connect a chaos delegate within a project + chaosctl connect chaos-delegate --name="new-chaos-delegate" --project-id="d861b650-1549-4574-b2ba-ab754058dd04" --non-interactive Note: The default location of the config file is $HOME/.chaosconfig, and can be overridden by a --config flag `, @@ -59,6 +59,7 @@ var agentCmd = &cobra.Command{ userDetails, err := apis.GetProjectDetails(credentials) utils.PrintError(err) + // If projectID is not passed, then it creates a random project if newAgent.ProjectId == "" { var projectExists = false @@ -88,18 +89,18 @@ var agentCmd = &cobra.Command{ os.Exit(1) } - newAgent.AgentName, err = cmd.Flags().GetString("agent-name") + newAgent.AgentName, err = cmd.Flags().GetString("name") utils.PrintError(err) if newAgent.AgentName == "" { - utils.Red.Print("Error: --agent-name flag is empty") + utils.Red.Print("Error: --name flag is empty") os.Exit(1) } - newAgent.SkipSSL, err = cmd.Flags().GetBool("skip-agent-ssl") + newAgent.Description, err = cmd.Flags().GetString("description") utils.PrintError(err) - newAgent.Description, err = cmd.Flags().GetString("agent-description") + newAgent.SkipSSL, err = cmd.Flags().GetBool("skip-ssl") utils.PrintError(err) newAgent.PlatformName, err = cmd.Flags().GetString("platform-name") @@ -110,10 +111,10 @@ var agentCmd = &cobra.Command{ os.Exit(1) } - newAgent.ClusterType, err = cmd.Flags().GetString("cluster-type") + newAgent.ClusterType, err = cmd.Flags().GetString("chaos-delegate-type") utils.PrintError(err) if newAgent.ClusterType == "" { - utils.Red.Print("Error: --cluster-type flag is empty") + utils.Red.Print("Error: --chaos-delegate-type flag is empty") os.Exit(1) } @@ -199,7 +200,7 @@ var agentCmd = &cobra.Command{ } if isAgentExist { - utils.Red.Print("Agent name already exist") + utils.Red.Print("Chaos delegate name already exist") os.Exit(1) } @@ -228,14 +229,14 @@ var agentCmd = &cobra.Command{ } agent, err := apis.ConnectAgent(newAgent, credentials) if err != nil { - utils.Red.Println("\n❌ Agent connection failed: " + err.Error() + "\n") + utils.Red.Println("\n❌ Chaos delegate connection failed: " + err.Error() + "\n") os.Exit(1) } if agent.Data.UserAgentReg.Token != "" { path := fmt.Sprintf("%s/%s/%s.yaml", credentials.Endpoint, utils.ChaosYamlPath, agent.Data.UserAgentReg.Token) utils.White_B.Print("Applying YAML:\n", path) } else { - utils.Red.Print("\n🚫 Token Generation failed, Chaos Delegate installation failed\n") + utils.Red.Print("\n🚫 Token Generation failed, chaos delegate installation failed\n") os.Exit(1) } @@ -247,7 +248,6 @@ var agentCmd = &cobra.Command{ }, kubeconfig, false) if err != nil { utils.Red.Print("\n❌ Failed in applying connection yaml: \n" + yamlOutput) - utils.Red.Print("\n Error: \n" + err.Error()) os.Exit(1) } @@ -262,22 +262,22 @@ var agentCmd = &cobra.Command{ } func init() { - CreateCmd.AddCommand(agentCmd) + ConnectCmd.AddCommand(agentCmd) agentCmd.Flags().BoolP("non-interactive", "n", false, "Set it to true for non interactive mode | Note: Always set the boolean flag as --non-interactive=Boolean") agentCmd.Flags().StringP("kubeconfig", "k", "", "Set to pass kubeconfig file if it is not in the default location ($HOME/.kube/config)") agentCmd.Flags().String("tolerations", "", "Set to pass kubeconfig file if it is not in the default location ($HOME/.kube/config)") - agentCmd.Flags().String("project-id", "", "Set the project-id to install agent for the particular project. To see the projects, apply chaosctl get projects") - agentCmd.Flags().String("installation-mode", "cluster", "Set the installation mode for the kind of agent | Supported=cluster/namespace") - agentCmd.Flags().String("agent-name", "", "Set the agent name") - agentCmd.Flags().String("agent-description", "---", "Set the agent description") + agentCmd.Flags().String("project-id", "", "Set the project-id to install chaos-delegate for the particular project. To see the projects, apply chaosctl get projects") + agentCmd.Flags().String("installation-mode", "cluster", "Set the installation mode for the kind of chaos-delegate | Supported=cluster/namespace") + agentCmd.Flags().String("name", "", "Set the chaos-delegate name") + agentCmd.Flags().String("description", "---", "Set the chaos-delegate description") + agentCmd.Flags().Bool("skip-ssl", false, "Set whether agent will skip ssl/tls check (can be used for self-signed certs, if cert is not provided in portal)") agentCmd.Flags().String("platform-name", "Others", "Set the platform name. Supported- AWS/GKE/Openshift/Rancher/Others") - agentCmd.Flags().String("cluster-type", "external", "Set the cluster-type to external for external agents | Supported=external/internal") - agentCmd.Flags().String("node-selector", "", "Set the node-selector for agent components | Format: \"key1=value1,key2=value2\")") - agentCmd.Flags().String("namespace", "litmus", "Set the namespace for the agent installation") - agentCmd.Flags().String("service-account", "litmus", "Set the service account to be used by the agent") - agentCmd.Flags().Bool("skip-agent-ssl", false, "Set whether agent will skip ssl/tls check (can be used for self-signed certs, if cert is not provided in portal)") + agentCmd.Flags().String("chaos-delegate-type", "external", "Set the chaos-delegate-type to external for external chaos-delegates | Supported=external/internal") + agentCmd.Flags().String("node-selector", "", "Set the node-selector for chaos-delegate components | Format: \"key1=value1,key2=value2\")") + agentCmd.Flags().String("namespace", "litmus", "Set the namespace for the chaos-delegate installation") + agentCmd.Flags().String("service-account", "litmus", "Set the service account to be used by the chaos-delegate") agentCmd.Flags().Bool("ns-exists", false, "Set the --ns-exists=false if the namespace mentioned in the --namespace flag is not existed else set it to --ns-exists=true | Note: Always set the boolean flag as --ns-exists=Boolean") agentCmd.Flags().Bool("sa-exists", false, "Set the --sa-exists=false if the service-account mentioned in the --service-account flag is not existed else set it to --sa-exists=true | Note: Always set the boolean flag as --sa-exists=Boolean\"\n") } diff --git a/pkg/cmd/connect/connect.go b/pkg/cmd/connect/connect.go new file mode 100644 index 0000000..37a7e80 --- /dev/null +++ b/pkg/cmd/connect/connect.go @@ -0,0 +1,36 @@ +/* +Copyright © 2021 The LitmusChaos Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package connect + +import ( + "github.com/spf13/cobra" +) + +// ConnectCmd represents the connect command +var ConnectCmd = &cobra.Command{ + Use: "connect", + Short: `Connect resources for LitmusChaos agent plane. + Examples: + + #connect a chaos delegate + chaosctl connect chaos-delegate --name="new-chaos-delegate" --non-interactive + + #connect a chaos delegate within a project + chaosctl connect chaos-delegate --name="new-chaos-delegate" --project-id="d861b650-1549-4574-b2ba-ab754058dd04" --non-interactive + + Note: The default location of the config file is $HOME/.chaosconfig, and can be overridden by a --config flag + `, +} diff --git a/pkg/cmd/create/create.go b/pkg/cmd/create/create.go index 84b0e62..4712613 100644 --- a/pkg/cmd/create/create.go +++ b/pkg/cmd/create/create.go @@ -27,12 +27,6 @@ var CreateCmd = &cobra.Command{ #create a project chaosctl create project --name new-proj - #create an agent - chaosctl create agent --agent-name="new-agent" --non-interactive - - #create an agent within a project - chaosctl create agent --agent-name="new-agent" --project-id="d861b650-1549-4574-b2ba-ab754058dd04" --non-interactive - Note: The default location of the config file is $HOME/.chaosconfig, and can be overridden by a --config flag `, } diff --git a/pkg/cmd/get/agents.go b/pkg/cmd/get/agents.go index 7b30003..5c71f2e 100644 --- a/pkg/cmd/get/agents.go +++ b/pkg/cmd/get/agents.go @@ -27,7 +27,7 @@ import ( // agentsCmd represents the agents command var agentsCmd = &cobra.Command{ - Use: "agents", + Use: "chaos-delegates", Short: "Display list of chaos delegates within the project", Long: `Display list of chaos delegates within the project`, Run: func(cmd *cobra.Command, args []string) { @@ -70,7 +70,7 @@ var agentsCmd = &cobra.Command{ case "": writer := tabwriter.NewWriter(os.Stdout, 4, 8, 1, '\t', 0) - utils.White_B.Fprintln(writer, "AGENTID\tAGENTNAME\tSTATUS\t") + utils.White_B.Fprintln(writer, "CHAOS DELEGATE ID\tCHAOS DELEGATE NAME\tSTATUS\t") for _, agent := range agents.Data.GetAgent { var status string diff --git a/pkg/cmd/get/get.go b/pkg/cmd/get/get.go index f8fd8eb..af51211 100644 --- a/pkg/cmd/get/get.go +++ b/pkg/cmd/get/get.go @@ -27,7 +27,7 @@ var GetCmd = &cobra.Command{ chaosctl get projects #get list of chaos delegates within the project - chaosctl get agents --project-id="" + chaosctl get chaos-delegates --project-id="" Note: The default location of the config file is $HOME/.chaosconfig, and can be overridden by a --config flag `, diff --git a/pkg/cmd/root/root.go b/pkg/cmd/root/root.go index 8bb38f4..c4fc9aa 100644 --- a/pkg/cmd/root/root.go +++ b/pkg/cmd/root/root.go @@ -23,6 +23,7 @@ import ( "net/http" "os" + "github.com/chaosnative/chaosctl/pkg/cmd/connect" "github.com/chaosnative/chaosctl/pkg/cmd/hubgen" "github.com/chaosnative/chaosctl/pkg/cmd/upgrade" @@ -58,6 +59,7 @@ func init() { cobra.OnInitialize(initConfig) rootCmd.AddCommand(config.ConfigCmd) + rootCmd.AddCommand(connect.ConnectCmd) rootCmd.AddCommand(create.CreateCmd) rootCmd.AddCommand(get.GetCmd) rootCmd.AddCommand(version.VersionCmd) @@ -69,7 +71,7 @@ func init() { // will be global for your application. rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.chaosconfig)") - rootCmd.PersistentFlags().BoolVar(&config2.SkipSSLVerify, "skipSSL", false, "skipSSL, litmusctl will skip ssl/tls verification while communicating with portal") + rootCmd.PersistentFlags().BoolVar(&config2.SkipSSLVerify, "skip-ssl", false, "skip-ssl, chaosctl will skip ssl/tls verification while communicating with portal") rootCmd.PersistentFlags().StringVar(&config2.CACert, "cacert", "", "cacert , custom ca certificate used for communicating with portal") } diff --git a/pkg/cmd/upgrade/agent.go b/pkg/cmd/upgrade/agent.go index ffb8af1..de1e759 100644 --- a/pkg/cmd/upgrade/agent.go +++ b/pkg/cmd/upgrade/agent.go @@ -29,7 +29,7 @@ import ( // createCmd represents the create command var agentCmd = &cobra.Command{ - Use: "agent", + Use: "chaos-delegate", Short: `Upgrades the ChaosNative Cloud chaos delegate plane.`, Run: func(cmd *cobra.Command, args []string) { credentials, err := utils.GetCredentials(cmd) @@ -50,12 +50,12 @@ var agentCmd = &cobra.Command{ } } - cluster_id, err := cmd.Flags().GetString("cluster-id") + cluster_id, err := cmd.Flags().GetString("chaos-delegate-id") utils.PrintError(err) if cluster_id == "" { prompt := promptui.Prompt{ - Label: "What's the ClusterID?", + Label: "What's the chaos delegate ID?", } cluster_id, err = prompt.Run() @@ -73,5 +73,5 @@ var agentCmd = &cobra.Command{ func init() { UpgradeCmd.AddCommand(agentCmd) agentCmd.Flags().String("project-id", "", "Enter the project ID") - agentCmd.Flags().String("cluster-id", "", "Enter the cluster ID") + agentCmd.Flags().String("chaos-delegate-id", "", "Enter the chaos delegate ID") } diff --git a/pkg/cmd/upgrade/upgrade.go b/pkg/cmd/upgrade/upgrade.go index ea80988..ee20cd6 100644 --- a/pkg/cmd/upgrade/upgrade.go +++ b/pkg/cmd/upgrade/upgrade.go @@ -24,7 +24,7 @@ var UpgradeCmd = &cobra.Command{ Use: "upgrade", Short: `Examples: #upgrade version of your chaos delegate - chaosctl upgrade agent --cluster-id="4cc25543-36c8-4373-897b-2e5dbbe87bcf" --project-id="d861b650-1549-4574-b2ba-ab754058dd04" --non-interactive + chaosctl upgrade chaos-delegate --chaos-delegate-id="4cc25543-36c8-4373-897b-2e5dbbe87bcf" --project-id="d861b650-1549-4574-b2ba-ab754058dd04" --non-interactive Note: The default location of the config file is $HOME/.chaosconfig, and can be overridden by a --config flag `, diff --git a/pkg/k8s/operations.go b/pkg/k8s/operations.go index ae7ebbd..4b92c9c 100644 --- a/pkg/k8s/operations.go +++ b/pkg/k8s/operations.go @@ -169,7 +169,7 @@ start: } if ok { if podExists(podExistsParams{namespace, label}, kubeconfig) { - utils.Red.Println("\n🚫 There is an chaos delegate already present in this namespace. Please enter a different namespace") + utils.Red.Println("\n🚫 There is a chaos delegate already present in this namespace. Please enter a different namespace") goto start } else { nsExists = true
Type Description
--agent-description--description StringSet the agent description (default "---")Set the chaos delegate description (default "---")
--agent-name--name StringSet the cluster-type to external for external agents | Supported=external/internal (default "external")Set the chaos-delegate-type to external for external chaos delegates | Supported=external/internal (default "external")
--skip-agent-ssl--skip-ssl BooleanSet whether agent will skip ssl/tls check (can be used for self-signed certs, if cert is not provided in portal) (default false)Set whether chaos delegate will skip ssl/tls check (can be used for self-signed certs, if cert is not provided in portal) (default false)
--cluster-type--chaos-delegate-type StringSet the cluster-type to external for external agents | Supported=external/internal (default "external")Set the chaos-delegate-type to external for external chaos delegates | Supported=external/internal (default "external")
--installation-mode StringSet the installation mode for the kind of agent | Supported=cluster/namespace (default "cluster")Set the installation mode for the kind of chaos delegate | Supported=cluster/namespace (default "cluster")
--kubeconfig--namespace StringSet the namespace for the agent installation (default "litmus")Set the namespace for the chaos delegate installation (default "litmus")
--node-selector StringSet the node-selector for agent components | Format: key1=value1,key2=value2) + Set the node-selector for chaos delegate components | Format: key1=value1,key2=value2)
--non-interactive--service-account StringSet the service account to be used by the agent (default "litmus")Set the service account to be used by the chaos delegate (default "litmus")
--config Field Description
Chaos Delegate Name:Name: Enter a name of the chaos delegate which needs to be unique across the project
Chaos Delegate Description:Description: Fill in details about the chaos delegate