Skip to content

Commit

Permalink
Fixed uninstall command to take the version in kubernetes mode to uni…
Browse files Browse the repository at this point in the history
…nstall (#398)

* fixed versioning issue

* updated readme

* updated uninstall section in docs

* moved uninstall flag information in readme

* Updated docs for runtime version flag

* added documentation to CLI flag
  • Loading branch information
willdavsmith authored Jul 14, 2020
1 parent a45842c commit da5e4ce
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ To remove Dapr from your Kubernetes cluster, use the `uninstall` command with `-
$ dapr uninstall --kubernetes
```

You can uninstall a specific version of the Dapr runtime on kubernetes using `dapr uninstall --runtime-version`. You can find the list of versions in [Dapr Release](https://github.com/dapr/dapr/releases).

```bash
# Uninstall v0.1.0 runtime
$ dapr uninstall --runtime-version=v0.1.0 --kubernetes
```

### Launch Dapr and your app

The Dapr CLI lets you debug easily by launching both Dapr and your app.
Expand Down
6 changes: 4 additions & 2 deletions cmd/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/spf13/viper"
)

var uninstallVersion string
var uninstallKubernetes bool
var uninstallAll bool

Expand All @@ -33,7 +34,7 @@ var UninstallCmd = &cobra.Command{

if uninstallKubernetes {
print.InfoStatusEvent(os.Stdout, "Removing Dapr from your cluster...")
err = kubernetes.Uninstall()
err = kubernetes.Uninstall(uninstallVersion)
} else {
print.InfoStatusEvent(os.Stdout, "Removing Dapr from your machine...")
dockerNetwork := viper.GetString("network")
Expand All @@ -50,9 +51,10 @@ var UninstallCmd = &cobra.Command{
}

func init() {
UninstallCmd.Flags().BoolVar(&uninstallKubernetes, "kubernetes", false, "Uninstall Dapr from a Kubernetes cluster")
UninstallCmd.Flags().BoolVarP(&uninstallKubernetes, "kubernetes", "k", false, "Uninstall Dapr from a Kubernetes cluster")
UninstallCmd.Flags().BoolVar(&uninstallAll, "all", false, "Remove Redis container in addition to actor placement container")
UninstallCmd.Flags().String("install-path", "", "The optional location to uninstall Daprd binary from. The default is /usr/local/bin for Linux/Mac and C:\\dapr for Windows")
UninstallCmd.Flags().String("network", "", "The Docker network from which to remove the Dapr runtime")
UninstallCmd.Flags().StringVarP(&uninstallVersion, "runtime-version", "", "latest", "The version of the Dapr runtime to uninstall. for example: v0.1.0 (Kubernetes mode only)")
RootCmd.AddCommand(UninstallCmd)
}
1 change: 0 additions & 1 deletion docs/reference/dapr-init.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ dapr init [flags]
| `--install-path` | `DAPR_INSTALL_PATH` | `Linux & Mac: /usr/local/bin` `Windows: C:\dapr` | The optional location to install Dapr to. The default is /usr/local/bin for Linux/Mac and C:\dapr for Windows |
| `--kubernetes`, `-k` | | `false` | Deploy Dapr to a Kubernetes cluster |
| `--network` | `DAPR_NETWORK` | | The Docker network on which to deploy the Dapr runtime |
| `--runtime-version` | | `latest` | The version of the Dapr runtime to install. for example: v0.1.0 (default "latest") |
| `--runtime-version` | | `latest` | The version of the Dapr runtime to install, for example: `v0.1.0-alpha` |
| `--redis-host` | `DAPR_REDIS_HOST` | `localhost` | The host on which the Redis service resides |
| `--install-path` | | `/usr/local/bin` for Linux/Mac and `C:\dapr` for Windows | The optional location to install Dapr to. |
Expand Down
3 changes: 2 additions & 1 deletion docs/reference/dapr-uninstall.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dapr uninstall [flags]
| --- | --- | --- | --- |
| `--all` | | `false` | Remove Redis, Zipkin containers in addition to actor placement container. Remove default dapr dir located at `$HOME/.dapr or %USERPROFILE%\.dapr\`. |
| `--help`, `-h` | | | Help for uninstall |
| `--kubernetes` | | `false` | Uninstall Dapr from a Kubernetes cluster |
| `--kubernetes`, `-k` | | `false` | Uninstall Dapr from a Kubernetes cluster |
| `--network` | `DAPR_NETWORK` | | The Docker network from which to remove the Dapr runtime |
| `--runtime-version` | | `latest` | The version of the Dapr runtime to uninstall, for example: `v0.1.0-alpha` (Kubernetes mode only) |
| `--install-path` | | `/usr/local/bin` for Linux/Mac and `C:\dapr` for Windows | The optional location to uninstall Dapr from. Use if provided during `dapr init`|
16 changes: 10 additions & 6 deletions pkg/kubernetes/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@ import (
)

// Uninstall removes Dapr
func Uninstall() error {
version, err := cli_ver.GetLatestRelease(cli_ver.DaprGitHubOrg, cli_ver.DaprGitHubRepo)
if err != nil {
return fmt.Errorf("cannot get the manifest file: %s", err)
func Uninstall(version string) error {
if version == daprLatestVersion {
v, err := cli_ver.GetLatestRelease(cli_ver.DaprGitHubOrg, cli_ver.DaprGitHubRepo)
if err != nil {
return fmt.Errorf("cannot get the manifest file: %s", err)
}

version = v
}

var daprManifestPath string = "https://github.com/dapr/dapr/releases/download/" + version + "/dapr-operator.yaml"
var daprManifestPath string = fmt.Sprintf("https://github.com/dapr/dapr/releases/download/%s/dapr-operator.yaml", version)

_, err = utils.RunCmdAndWait("kubectl", "delete", "-f", daprManifestPath)
_, err := utils.RunCmdAndWait("kubectl", "delete", "-f", daprManifestPath)
if err != nil {
return errors.New("is Dapr running? uninstall does not remove Dapr when installed via Helm")
}
Expand Down

0 comments on commit da5e4ce

Please sign in to comment.