安装 Dapr CLI 脚手架工具

Dapr CLI 是您用于各种 Dapr 相关任务的主要工具。 您可以使用它来运行一个带有Dapr sidecar的应用程序, 以及查看sidecar日志、列出运行中的服务、运行 Dapr 仪表板。 The Dapr CLI works with both self-hosted and Kubernetes environments.

开始下载并安装 Dapr CLI:

此命令将安装最新的 Linux Dapr CLI 到 /usr/local/bin

  1. wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash

此命令提示命令将安装最新的 Windows Dapr CLI 到 C:\dapr 并将此目录添加到用户PATH 环境变量。

  1. powershell -Command "iwr -useb https://raw.githubusercontent.com/dapr/cli/master/install/install.ps1 | iex"

此命令将安装最新的 darwin Dapr CLI 到 /usr/local/bin:

  1. curl -fsSL https://raw.githubusercontent.com/dapr/cli/master/install/install.sh | /bin/bash

或者您可以通过 Homebrew 进行安装:

  1. brew install dapr/tap/dapr-cli

Note for M1 Macs

  1. <p>M1 Mac不支持homebrew 您需要使用 Dapr 安装脚本并安装 rosetta amd64 兼容层。 如果你没有安装它,你可以运行:</p>
  1. softwareupdate --install-rosetta

每次发行的Dapr CLI包括各种操作系统和架构。 这些二进制版本可以手动下载和安装。

  1. 从最新的 Dapr Releases中下载所需的 Dapr CLI
  2. 解压它(例如,dapr_linux_amd64.tar.gz, dapr_windows_amd64.zip)
  3. 将其移动到你想要的位置。
    • 用于 Linux/MacOS - /usr/local/bin
    • 对于Windows,创建一个目录并将其添加到系统PATH。 例如,通过编辑系统环境变量,创建一个名为 C:\dapr 的目录,并将此目录添加到您的用户PATH。

步骤 2:验证安装

您可以通过重新启动您的终端/命令提示和运行以下操作来验证CLI:

  1. dapr

输出显示应该如下方所示:

  1. __
  2. ____/ /___ _____ _____
  3. / __ / __ '/ __ \/ ___/
  4. / /_/ / /_/ / /_/ / /
  5. \__,_/\__,_/ .___/_/
  6. /_/
  7. ===============================
  8. Distributed Application Runtime
  9. Usage:
  10. dapr [command]
  11. Available Commands:
  12. completion Generates shell completion scripts
  13. components List all Dapr components. Supported platforms: Kubernetes
  14. configurations List all Dapr configurations. Supported platforms: Kubernetes
  15. dashboard Start Dapr dashboard. Supported platforms: Kubernetes and self-hosted
  16. help Help about any command
  17. init Install Dapr on supported hosting platforms. Supported platforms: Kubernetes and self-hosted
  18. invoke Invoke a method on a given Dapr application. Supported platforms: Self-hosted
  19. list List all Dapr instances. Supported platforms: Kubernetes and self-hosted
  20. logs Get Dapr sidecar logs for an application. Supported platforms: Kubernetes
  21. mtls Check if mTLS is enabled. Supported platforms: Kubernetes
  22. publish Publish a pub-sub event. Supported platforms: Self-hosted
  23. run Run Dapr and (optionally) your application side by side. Supported platforms: Self-hosted
  24. status Show the health status of Dapr services. Supported platforms: Kubernetes
  25. stop Stop Dapr instances and their associated apps. . Supported platforms: Self-hosted
  26. uninstall Uninstall Dapr runtime. Supported platforms: Kubernetes and self-hosted
  27. upgrade Upgrades a Dapr control plane installation in a cluster. Supported platforms: Kubernetes
  28. Flags:
  29. -h, --help help for dapr
  30. -v, --version version for dapr
  31. Use "dapr [command] --help" for more information about a command.

下一步: 初始化 Dapr >>