Skip to content

Commit

Permalink
Merge pull request #583 from dapr/master
Browse files Browse the repository at this point in the history
Merge master into release branch.
  • Loading branch information
wcs1only authored Jan 27, 2021
2 parents ecb3453 + 49afc98 commit b589bbf
Show file tree
Hide file tree
Showing 20 changed files with 781 additions and 202 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ cli
*.out

.vscode
.idea

# Visual Studio 2015/2017/2019 cache/options directory
.vs/
Expand Down
38 changes: 37 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ $ dapr uninstall --network dapr-network

The init command will install Dapr to a Kubernetes cluster. For more advanced use cases, use our [Helm Chart](https://github.com/dapr/dapr/tree/master/charts/dapr).

*Note: The default namespace is dapr-system*
*Note: The default namespace is dapr-system. The installation will appear under the name `dapr` for Helm*

```
$ dapr init -k
Expand All @@ -185,6 +185,14 @@ $ dapr init -k
✅ Success! Dapr has been installed to namespace dapr-system. To verify, run "dapr status -k" in your terminal. To get started, go here: https://aka.ms/dapr-getting-started
```

#### Supplying Helm values

All available [Helm Chart values](https://github.com/dapr/dapr/tree/master/charts/dapr#configuration) can be set by using the `--set` flag:

```
$ dapr init -k --set global.tag=0.11.2 --set dapr_operator.logLevel=error
```

#### Installing to a custom namespace

```
Expand All @@ -211,6 +219,26 @@ To remove Dapr from your Kubernetes cluster, use the `uninstall` command with `-
$ dapr uninstall -k
```

### Upgrade Dapr on Kubernetes

To perform a zero downtime upgrade of the Dapr control plane:

```
$ dapr upgrade -k --runtime-version=1.0.0-rc.2
```

The example above shows how to upgrade from your current version to version `1.0.0-rc.2`.

#### Supplying Helm values

All available [Helm Chart values](https://github.com/dapr/dapr/tree/master/charts/dapr#configuration) can be set by using the `--set` flag:

```
$ dapr upgrade -k --runtime-version=1.0.0-rc.2 --set global.tag=0.11.2 --set dapr_operator.logLevel=error
```

*Note: do not use the `dapr upgrade` command if you're upgrading from 0.x versions of Dapr*

### Launch Dapr and your app

The Dapr CLI lets you debug easily by launching both Dapr and your app.
Expand Down Expand Up @@ -420,6 +448,14 @@ If you want to manually assign a profiling port, use the `profile-port` flag:
$ dapr run --app-id nodeapp --app-port 3000 node app.js --enable-profiling --profile-port 7777
```

### Set metrics server port

To change the metrics server port used by Dapr, set the `metrics-port` flag:

```
$ dapr run --app-id nodeapp --app-port 3000 node app.js --metrics-port 5040
```

### Set log level

In order to set the Dapr runtime log verbosity level, use the `log-level` flag:
Expand Down
10 changes: 5 additions & 5 deletions cmd/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ const (
)

var (
dashboardNamespace string
dashboardLocalPort int
dashboardVersion bool
dashboardNamespace string
dashboardLocalPort int
dashboardVersionCmd bool
)

var DashboardCmd = &cobra.Command{
Expand All @@ -60,7 +60,7 @@ dapr dashboard -k
dapr dashboard -k -p 9999
`,
Run: func(cmd *cobra.Command, args []string) {
if dashboardVersion {
if dashboardVersionCmd {
fmt.Println(standalone.GetDashboardVersion())
os.Exit(0)
}
Expand Down Expand Up @@ -166,7 +166,7 @@ dapr dashboard -k -p 9999

func init() {
DashboardCmd.Flags().BoolVarP(&kubernetesMode, "kubernetes", "k", false, "Opens Dapr dashboard in local browser via local proxy to Kubernetes cluster")
DashboardCmd.Flags().BoolVarP(&dashboardVersion, "version", "v", false, "Print the version for Dapr dashboard")
DashboardCmd.Flags().BoolVarP(&dashboardVersionCmd, "version", "v", false, "Print the version for Dapr dashboard")
DashboardCmd.Flags().IntVarP(&dashboardLocalPort, "port", "p", defaultLocalPort, "The local port on which to serve Dapr dashboard")
DashboardCmd.Flags().StringVarP(&dashboardNamespace, "namespace", "n", daprSystemNamespace, "The namespace where Dapr dashboard is running")
DashboardCmd.Flags().BoolP("help", "h", false, "Print this help message")
Expand Down
22 changes: 13 additions & 9 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ import (
)

var (
kubernetesMode bool
slimMode bool
runtimeVersion string
initNamespace string
enableMTLS bool
enableHA bool
kubernetesMode bool
slimMode bool
runtimeVersion string
dashboardVersion string
initNamespace string
enableMTLS bool
enableHA bool
values []string
)

var InitCmd = &cobra.Command{
Expand Down Expand Up @@ -53,13 +55,14 @@ dapr init -s
print.PendingStatusEvent(os.Stdout, "Making the jump to hyperspace...")

if kubernetesMode {
print.InfoStatusEvent(os.Stdout, "Note: To install Dapr using Helm, see here: https://docs.dapr.io/getting-started/install-dapr/#install-with-helm-advanced\n")
print.InfoStatusEvent(os.Stdout, "Note: To install Dapr using Helm, see here: https://docs.dapr.io/getting-started/install-dapr-kubernetes/#install-with-helm-advanced\n")

config := kubernetes.InitConfiguration{
Namespace: initNamespace,
Version: runtimeVersion,
EnableMTLS: enableMTLS,
EnableHA: enableHA,
Args: values,
}
err := kubernetes.Init(config)
if err != nil {
Expand All @@ -72,7 +75,7 @@ dapr init -s
if !slimMode {
dockerNetwork = viper.GetString("network")
}
err := standalone.Init(runtimeVersion, dockerNetwork, slimMode)
err := standalone.Init(runtimeVersion, dashboardVersion, dockerNetwork, slimMode)
if err != nil {
print.FailureStatusEvent(os.Stdout, err.Error())
return
Expand All @@ -86,11 +89,12 @@ func init() {
InitCmd.Flags().BoolVarP(&kubernetesMode, "kubernetes", "k", false, "Deploy Dapr to a Kubernetes cluster")
InitCmd.Flags().BoolVarP(&slimMode, "slim", "s", false, "Exclude placement service, Redis and Zipkin containers from self-hosted installation")
InitCmd.Flags().StringVarP(&runtimeVersion, "runtime-version", "", "latest", "The version of the Dapr runtime to install, for example: 1.0.0")
InitCmd.Flags().StringVarP(&dashboardVersion, "dashboard-version", "", "latest", "The version of the Dapr dashboard to install, for example: 1.0.0")
InitCmd.Flags().StringVarP(&initNamespace, "namespace", "n", "dapr-system", "The Kubernetes namespace to install Dapr in")
InitCmd.Flags().BoolVarP(&enableMTLS, "enable-mtls", "", true, "Enable mTLS in your cluster")
InitCmd.Flags().BoolVarP(&enableHA, "enable-ha", "", false, "Enable high availability (HA) mode")
InitCmd.Flags().String("network", "", "The Docker network on which to deploy the Dapr runtime")
InitCmd.Flags().BoolP("help", "h", false, "Print this help message")

InitCmd.Flags().StringArrayVar(&values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)")
RootCmd.AddCommand(InitCmd)
}
3 changes: 3 additions & 0 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var (
protocol string
componentsPath string
appSSL bool
metricsPort int
)

const (
Expand Down Expand Up @@ -81,6 +82,7 @@ var RunCmd = &cobra.Command{
PlacementHost: viper.GetString("placement-host-address"),
ComponentsPath: componentsPath,
AppSSL: appSSL,
MetricsPort: metricsPort,
})
if err != nil {
print.FailureStatusEvent(os.Stdout, err.Error())
Expand Down Expand Up @@ -238,6 +240,7 @@ func init() {
RunCmd.Flags().StringVarP(&componentsPath, "components-path", "d", standalone.DefaultComponentsDirPath(), "The path for components directory")
RunCmd.Flags().String("placement-host-address", "localhost", "The host on which the placement service resides")
RunCmd.Flags().BoolVar(&appSSL, "app-ssl", false, "Enable https when Dapr invokes the application")
RunCmd.Flags().IntVarP(&metricsPort, "metrics-port", "M", -1, "The port of metrics on dapr")
RunCmd.Flags().BoolP("help", "h", false, "Print this help message")
RootCmd.AddCommand(RunCmd)
}
48 changes: 48 additions & 0 deletions cmd/upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------

package cmd

import (
"os"

"github.com/dapr/cli/pkg/kubernetes"
"github.com/dapr/cli/pkg/print"
"github.com/spf13/cobra"
)

var UpgradeCmd = &cobra.Command{
Use: "upgrade",
Short: "Upgrades a Dapr control plane installation in a cluster. Supported platforms: Kubernetes",
Example: `
# Upgrade Dapr in Kubernetes
dapr upgrade -k
# See more at: https://docs.dapr.io/getting-started/
`,
Run: func(cmd *cobra.Command, args []string) {
err := kubernetes.Upgrade(kubernetes.UpgradeConfig{
RuntimeVersion: runtimeVersion,
Args: values,
})
if err != nil {
print.FailureStatusEvent(os.Stdout, "Failed to upgrade Dapr: %s", err)
return
}
print.SuccessStatusEvent(os.Stdout, "Dapr control plane successfully upgraded to version %s. Make sure your deployments are restarted to pick up the latest sidecar version.", runtimeVersion)
},
}

func init() {
UpgradeCmd.Flags().BoolVarP(&kubernetesMode, "kubernetes", "k", false, "Upgrade Dapr in a Kubernetes cluster")
UpgradeCmd.Flags().StringVarP(&runtimeVersion, "runtime-version", "", "", "The version of the Dapr runtime to upgrade to, for example: 1.0.0")
UpgradeCmd.Flags().BoolP("help", "h", false, "Print this help message")
UpgradeCmd.Flags().StringArrayVar(&values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)")

UpgradeCmd.MarkFlagRequired("runtime-version")
UpgradeCmd.MarkFlagRequired("kubernetes")

RootCmd.AddCommand(UpgradeCmd)
}
20 changes: 11 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/Pallinder/sillyname-go v0.0.0-20130730142914-97aeae9e6ba1
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/briandowns/spinner v1.6.1
github.com/dapr/dapr v1.0.0-rc.1.0.20201211012322-e192d1215eb3
github.com/dapr/dapr v1.0.0-rc.1.0.20201217002310-310e670d987b
github.com/docker/docker v17.12.0-ce-rc1.0.20200618181300-9dc6525e6118+incompatible
github.com/fatih/color v1.7.0
github.com/go-ole/go-ole v1.2.4 // indirect
Expand All @@ -16,20 +16,22 @@ require (
github.com/mattn/go-runewidth v0.0.8 // indirect
github.com/mitchellh/go-ps v0.0.0-20190716172923-621e5597135b
github.com/nightlyone/lockfile v0.0.0-20180618180623-0ad87eef1443
github.com/olekukonko/tablewriter v0.0.1
github.com/olekukonko/tablewriter v0.0.2
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4
github.com/shirou/gopsutil v2.20.2+incompatible
github.com/spf13/cobra v0.0.6
github.com/spf13/viper v1.5.0
github.com/spf13/cobra v1.1.1
github.com/spf13/viper v1.7.0
github.com/stretchr/testify v1.6.1
gopkg.in/yaml.v2 v2.3.0
helm.sh/helm/v3 v3.1.0
k8s.io/api v0.17.8
k8s.io/apimachinery v0.17.8
k8s.io/cli-runtime v0.17.8
k8s.io/client-go v0.17.8
helm.sh/helm/v3 v3.4.0
k8s.io/api v0.20.0
k8s.io/apiextensions-apiserver v0.20.0
k8s.io/apimachinery v0.20.0
k8s.io/cli-runtime v0.20.0
k8s.io/client-go v0.20.0
k8s.io/helm v2.16.10+incompatible
k8s.io/kubectl v0.20.0 // indirect
rsc.io/letsencrypt v0.0.3 // indirect
)

Expand Down
Loading

0 comments on commit b589bbf

Please sign in to comment.