Skip to content

Commit

Permalink
Updating chaosctl docs and minor changes in the cli (#4)
Browse files Browse the repository at this point in the history
* changing name to access_id and access_key

Signed-off-by: rajdas98 <[email protected]>

* changes in the platform options

Signed-off-by: rajdas98 <[email protected]>

* updating doc

Signed-off-by: rajdas98 <[email protected]>
  • Loading branch information
imrajdas authored Jan 25, 2022
1 parent 65ef052 commit 970ca92
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 60 deletions.
8 changes: 4 additions & 4 deletions Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Note: With namespace mode, the user needs to create the namespace to install the

* To setup an account with chaosctl
```shell
chaosctl config set-account --endpoint="" --username="" --password=""
chaosctl config set-account --endpoint="" --access_id="" --access_key=""
```

* To create an agent without a project
Expand Down Expand Up @@ -168,14 +168,14 @@ chaosctl config get-accounts
**Output:**

```
CURRENT ENDPOINT USERNAME EXPIRESIN
CURRENT ENDPOINT ACCESSID EXPIRESIN
https://preview.litmuschaos.io admin 2021-07-22 01:20:27 +0530 IST
* https://preview.litmuschaos.io raj 2021-07-22 14:33:22 +0530 IST
```

* To alter the current account use the `use-account` command with the --endpoint and --username flags:
* To alter the current account use the `use-account` command with the --endpoint and --access_id flags:
```shell
chaosctl config use-account --endpoint="" --username=""
chaosctl config use-account --endpoint="" --access_id=""
```

* To create a project, apply the following command with the `--name` flag:
Expand Down
81 changes: 44 additions & 37 deletions Usage_interactive.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,24 @@ chaosctl supports both interactive and non-interactive(flag based) modes.
chaosctl config set-account
```

Next, you need to enter ChaosCenter details to login into your ChaosCenter account. Fields to be filled in:
Next, you need to enter CLC/CLE details to login into your account. Fields to be filled in:

**ChaosCenter URL:** Enter the URL used to access the ChaosCenter.
**What's the product name:** Select the product name .

> Example, https://preview.litmuschaos.io/
**Username:** Enter your ChaosCenter username. <br />
**Password:** Enter your ChaosCenter password.
**AccessID:** What's the AccessID?: <br />
**AccessKey:** What's the AccessKey?:

```
Host endpoint where litmus is installed: https://preview.litmuschaos.io/
Username [Default: admin]: admin
Password:
account.username/admin configured
? What's the product name?:
▸ ChaosNative Cloud
ChaosNative Enterprise
What's the AccessID?: Raj60163RjxQE
What's the AccessKey?: ***************
account.accessID/admin configured
```

- To create an agent in a cluster mode
Expand All @@ -55,15 +58,13 @@ chaosctl create agent
There will be a list of existing projects displayed on the terminal. Select the desired project by entering the sequence number indicated against it.

```
Project list:
1. Project-Admin
Select a project [Range: 1-1]: 1
? Select a project from the list:
▸ Raj60163's project
```

Next, select the installation mode based on your requirement by entering the sequence number indicated against it.

Chaosctl can install an agent in two different modes.
It can install an agent 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.

Expand All @@ -72,11 +73,9 @@ Chaosctl can install an agent in two different modes.
Note: With namespace mode, the user needs to create the namespace to install the agent as a prerequisite.

```
Installation Modes:
1. Cluster
2. Namespace
Select Mode [Default: cluster] [Range: 1-2]: 1
? What's the installation mode?:
▸ Cluster
Namespace
🏃 Running prerequisites check....
🔑 clusterrole ✅
Expand Down Expand Up @@ -120,24 +119,28 @@ Fields to be filled in <br />

```
Enter the details of the agent
✔ What's the Agent Name?: new-agent
Agent Name: New-Agent
✔ Add your agent description: new-agent█
Agent Description: This is a new agent
? Do you want NodeSelectors added to the agent deployments?:
Yes
▸ No
Do you want NodeSelector to be added in the agent deployments (Y/N) (Default: N): N
? Do you want Tolerations added in the agent deployments??:
Yes
▸ No
Platform List:
1. AWS
2. GKE
3. Openshift
4. Rancher
5. Others
? What's your Kubernetes Platform?:
▸ Others
AWS Elastic Kubernetes Service
Google Kubernetes Service
OpenShift
Rancher
Select a platform [Default: Others] [Range: 1-5]: 5
✔ Enter a new or existing namespace [Default: litmus ]: new-ns
Enter the namespace (new or existing namespace) [Default: litmus]:
👍 Continuing with litmus namespace
✔ Enter a service account [Default: litmus ]:
```

Once, all these steps are implemented you will be able to see a summary of all the entered fields.
Expand All @@ -152,10 +155,12 @@ Agent Description: This is a new agent
Platform Name: Others
Namespace: litmus
Service Account: litmus (new)
Installation Mode: cluster
🤷 Do you want to continue with the above details? [Y/N]: Y
? Do you want to continue with the above details?:
▸ Yes
No
👍 Continuing agent connection!!
Applying YAML:
https://preview.litmuschaos.io/api/file/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbHVzdGVyX2lkIjoiMDUyZmFlN2UtZGM0MS00YmU4LWJiYTgtMmM4ZTYyNDFkN2I0In0.i31QQDG92X5nD6P_-7TfeAAarZqLvUTFfnAghJYXPiM.yaml
Expand Down Expand Up @@ -208,7 +213,7 @@ chaosctl config get-accounts
**Output:**

```
CURRENT ENDPOINT USERNAME EXPIRESIN
CURRENT ENDPOINT ACCESSID EXPIRESIN
https://preview.litmuschaos.io admin 2021-07-22 01:20:27 +0530 IST
* https://preview.litmuschaos.io raj 2021-07-22 14:33:22 +0530 IST
```
Expand All @@ -218,9 +223,11 @@ CURRENT ENDPOINT USERNAME EXPIRESIN
```shell
chaosctl config use-account

Host endpoint where litmus is installed: https://preview.litmuschaos.io

Username: admin
? What's the product name?:
▸ ChaosNative Cloud
ChaosNative Enterprise
What's the AccessID?: Raj60163RjxQE
```

- To create a project, apply the following command :
Expand Down
1 change: 1 addition & 0 deletions pkg/agent/ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ AGENT_NAME:
if ok := utils.CheckKeyValueFormat(newAgent.NodeSelector); !ok {
os.Exit(1)
}

if err != nil {
utils.Red.Println(errors.New("Prompt err:" + err.Error()))
os.Exit(1)
Expand Down
27 changes: 10 additions & 17 deletions pkg/agent/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,22 @@ import (
// - String literals like "AWS" are used at multiple places. Need to be changed to constants.
func GetPlatformName(kubeconfig *string) string {

items := []string{"AWS Elastic Kubernetes Service", "Google Kubernetes Service", "OpenShift", "Rancher"}
index := -1
items := []string{"Others", "AWS Elastic Kubernetes Service", "Google Kubernetes Service", "OpenShift", "Rancher"}
var (
result string
err error
)

for index < 0 {
prompt := promptui.SelectWithAdd{
Label: "What's your Kubernetes Platform?",
Items: items,
AddLabel: "Other",
}

index, result, err = prompt.Run()
if err != nil {
utils.Red.Println(errors.New("Prompt err:" + err.Error()))
os.Exit(1)
}
prompt := promptui.Select{
Label: "What's your Kubernetes Platform?",
Items: items,
Size: len(items),
}

if index == -1 {
items = append(items, result)
}
_, result, err = prompt.Run()
if err != nil {
utils.Red.Println(errors.New("Prompt err:" + err.Error()))
os.Exit(1)
}

return result
Expand Down
4 changes: 2 additions & 2 deletions pkg/k8s/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ start:

if mode == "namespace" {
prompt := promptui.Prompt{
Label: "Enter an existing namespace [Default: " + utils.DefaultNs + " ]:",
Label: "Enter an existing namespace [Default: " + utils.DefaultNs + " ]",
}

namespace, err = prompt.Run()
Expand All @@ -145,7 +145,7 @@ start:

} else if mode == "cluster" {
prompt := promptui.Prompt{
Label: "Enter a new or existing namespace [Default: " + utils.DefaultNs + " ]:",
Label: "Enter a new or existing namespace [Default: " + utils.DefaultNs + " ]",
}

namespace, err = prompt.Run()
Expand Down

0 comments on commit 970ca92

Please sign in to comment.