Skip to content

Commit

Permalink
Updates the CLI name to crashd
Browse files Browse the repository at this point in the history
- Updates the CAPI provider docs to reflect new/updated parameter names
- Updates the kube_config(), capa_provider() and capv_provider()
directives to consume/return k8s configuration as `kube_config`
  • Loading branch information
srm09 committed Aug 6, 2020
1 parent f40f49c commit 7384add
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 15 deletions.
12 changes: 8 additions & 4 deletions cmd/crash-dianostics.go
Expand Up @@ -4,14 +4,18 @@
package cmd

import (
"fmt"
"os"

"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/vmware-tanzu/crash-diagnostics/buildinfo"
)

const defaultLogLevel = logrus.InfoLevel
const (
defaultLogLevel = logrus.InfoLevel
CliName = "crashd"
)

// globalFlags flags for the command
type globalFlags struct {
Expand All @@ -23,9 +27,9 @@ func crashDiagnosticsCommand() *cobra.Command {
flags := &globalFlags{debug: false}
cmd := &cobra.Command{
Args: cobra.NoArgs,
Use: "crash-diagnostics",
Short: "crash-diagnostics helps to troubleshoot kubernetes cluster",
Long: "crash-diagnostics collects diagnostics from an unresponsive Kubernetes cluster",
Use: CliName,
Short: fmt.Sprintf("%s helps to troubleshoot kubernetes cluster", CliName),
Long: fmt.Sprintf("%s collects diagnostics from an unresponsive Kubernetes cluster", CliName),
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
return preRun(flags)
},
Expand Down
42 changes: 40 additions & 2 deletions docs/README.md
Expand Up @@ -190,7 +190,44 @@ This function configures the Cluster-API provider for AWS (CAPA). This provider
#### Parameters
| Param | Description | Required |
| -------- | -------- | -------- |
| | | |
| `ssh_config`|SSH configuration returned by `ssh_config()`|Yes |
| `mgmt_kube_config` |Kubernetes configuration returned by `kube_config`|Yes|
| `workload_cluster`|The name of a workload cluster. When specified the provider will retrieve a cluster's compute nodes for the workload cluster.|No|
| `namespace`|The namespace in which the workload cluster was created, if `workload_cluster` is specified. If no `workload_cluster` is specified, then this should be the namespace of the management cluster.|No|
| `labels`|A list of labels used to filter cluster's compute nodes|No|
| `nodes` |A list of node names that can filter selected cluster nodes|No|

#### Output
`capa_provider()` returns a struct with the following fields.

| Field | Description |
| --------| --------- |
| `kind`| The name of the provider (`capv_provider`)|
|`transport`|The name of the transport to use (i.e. `ssh, http, etc`)|
| `ssh_config` | A struct with SSH configuration |
| `kube_config` | A struct with Kubernetes configuration |
| `workload_cluster` | The name of the |
| `hosts`|A list of host addresses generated from cluster information|

#### Example
```python

ssh=ssh_config(
username=os.username,
private_key_path="{0}/.ssh/id_rsa".format(os.home),
port=args.ssh_port,
max_retries=5,
)

kube=kube_config(path=args.kube_conf)

capa_provider(
workload_cluster="my-wc-cluster",
namespace="workloads"
ssh_config=ssh,
kube_config=kube
)
```

### `capv_provider()`
This function configures a provider for a Cluster-API managed cluster running on vSphere (CAPV). By default, this provider will enumerate cluster resources for the management cluster. However, by specifying the name of a `workload_cluster`, the provider will enumarate cluster compute resources for the workload cluster.
Expand All @@ -199,8 +236,9 @@ This function configures a provider for a Cluster-API managed cluster running on
| Param | Description | Required |
| -------- | -------- | -------- |
| `ssh_config`|SSH configuration returned by `ssh_config()`|Yes |
| `kube_config` |Kubernetes configuration returned by `kube_config`|Yes|
| `mgmt_kube_config` |Kubernetes configuration returned by `kube_config`|Yes|
| `workload_cluster`|The name of a workload cluster. When specified the provider will retrieve a cluster's compute nodes for the workload cluster.|No|
| `namespace`|The namespace in which the workload cluster was created, if `workload_cluster` is specified. If no `workload_cluster` is specified, then this should be the namespace of the management cluster.|No|
| `labels`|A list of labels used to filter cluster's compute nodes|No|
| `nodes` |A list of node names that can filter selected cluster nodes|No|

Expand Down
6 changes: 3 additions & 3 deletions starlark/capa_provider.go
Expand Up @@ -75,9 +75,9 @@ func CapaProviderFn(thread *starlark.Thread, _ *starlark.Builtin, args starlark.

// dictionary for capa provider struct
capaProviderDict := starlark.StringDict{
"kind": starlark.String(identifiers.capvProvider),
"transport": starlark.String("ssh"),
"kubeconfig": starlark.String(providerConfigPath),
"kind": starlark.String(identifiers.capvProvider),
"transport": starlark.String("ssh"),
"kube_config": starlark.String(providerConfigPath),
}

// add node info to dictionary
Expand Down
6 changes: 3 additions & 3 deletions starlark/capv_provider.go
Expand Up @@ -56,9 +56,9 @@ func CapvProviderFn(thread *starlark.Thread, _ *starlark.Builtin, args starlark.

// dictionary for capv provider struct
capvProviderDict := starlark.StringDict{
"kind": starlark.String(identifiers.capvProvider),
"transport": starlark.String("ssh"),
"kubeconfig": starlark.String(providerConfigPath),
"kind": starlark.String(identifiers.capvProvider),
"transport": starlark.String("ssh"),
"kube_config": starlark.String(providerConfigPath),
}

// add node info to dictionary
Expand Down
2 changes: 1 addition & 1 deletion starlark/kube_config.go
Expand Up @@ -40,7 +40,7 @@ func KubeConfigFn(_ *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple,
}
}

pathVal, err := provider.Attr("kubeconfig")
pathVal, err := provider.Attr("kube_config")
if err != nil {
return starlark.None, errors.Wrap(err, "could not find the kubeconfig attribute")
}
Expand Down
4 changes: 2 additions & 2 deletions starlark/kube_config_test.go
Expand Up @@ -104,7 +104,7 @@ var _ = Describe("KubeConfigFn", func() {
[]starlark.Value{
starlark.String("capi_provider"),
starlarkstruct.FromStringDict(starlark.String(identifiers.capvProvider), starlark.StringDict{
"kubeconfig": starlark.String("/foo/bar"),
"kube_config": starlark.String("/foo/bar"),
}),
},
})
Expand All @@ -124,7 +124,7 @@ var _ = Describe("KubeConfigFn", func() {
[]starlark.Value{
starlark.String("capi_provider"),
starlarkstruct.FromStringDict(starlark.String("meh"), starlark.StringDict{
"kubeconfig": starlark.String("/foo/bar"),
"kube_config": starlark.String("/foo/bar"),
}),
},
})
Expand Down

0 comments on commit 7384add

Please sign in to comment.