🎩

Dapr CLI をインストールする

2023/11/28に公開

気になっていたけど、検証したいことも出てきたので、ついに Dapr に手を出したいと思います・・・!
まずは、Dapr CLI のインストールから。

環境

WSL2 Ubuntu 22.04
Docker Desktop

Install the Dapr CLI

https://docs.dapr.io/getting-started/install-dapr-cli/

Step 1: Install the Dapr CLI

まずはインストール

wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash
Getting the latest Dapr CLI...
Your system is linux_amd64
Installing Dapr CLI...

Installing v1.12.0 Dapr CLI...
Downloading https://github.com/dapr/cli/releases/download/v1.12.0/dapr_linux_amd64.tar.gz ...
dapr installed into /usr/local/bin successfully.
CLI version: 1.12.0
Runtime version: n/a

To get started with Dapr, please visit https://docs.dapr.io/getting-started/

1.12 が入ったみたいです。

Step 2: Verify the installation

$ dapr -h

          __
     ____/ /___ _____  _____
    / __  / __ '/ __ \/ ___/
   / /_/ / /_/ / /_/ / /
   \__,_/\__,_/ .___/_/
             /_/

===============================
Distributed Application Runtime

Usage:
  dapr [flags]
  dapr [command]

Available Commands:
  annotate       Add dapr annotations to a Kubernetes configuration. Supported platforms: Kubernetes
  build-info     Print build info of Dapr CLI and runtime
  completion     Generates shell completion scripts
  components     List all Dapr components. Supported platforms: Kubernetes
  configurations List all Dapr configurations. Supported platforms: Kubernetes
  dashboard      Start Dapr dashboard. Supported platforms: Kubernetes and self-hosted
  help           Help about any command
  init           Install Dapr on supported hosting platforms. Supported platforms: Kubernetes and self-hosted
  invoke         Invoke a method on a given Dapr application. Supported platforms: Self-hosted
  list           List all Dapr instances. Supported platforms: Kubernetes and self-hosted
  logs           Get Dapr sidecar logs for an application. Supported platforms: Kubernetes
  mtls           Check if mTLS is enabled. Supported platforms: Kubernetes
  publish        Publish a pub-sub event. Supported platforms: Self-hosted
  run            Run Dapr and (optionally) your application side by side. Supported platforms: Self-hosted
  status         Show the health status of Dapr services. Supported platforms: Kubernetes
  stop           Stop Dapr instances and their associated apps. Supported platforms: Self-hosted
  uninstall      Uninstall Dapr runtime. Supported platforms: Kubernetes and self-hosted
  upgrade        Upgrades or downgrades a Dapr control plane installation in a cluster. Supported platforms: Kubernetes
  version        Print the Dapr runtime and CLI version

Flags:
  -h, --help                  help for dapr
      --log-as-json           Log output in JSON format
      --runtime-path string   The path to the dapr runtime installation directory
  -v, --version               version for dapr

Use "dapr [command] --help" for more information about a command.

Initialize Dapr in your local environment

Dapr の初期化をします。
docker を使うのでDocker Desktopなどデーモンが起動していないとダメみたいです。

Step 2: Run the init CLI command

$ dapr init
⌛  Making the jump to hyperspace...
ℹ️  Container images will be pulled from Docker Hub
ℹ️  Installing runtime version 1.12.2
↙  Downloading binaries and setting up components...
Dapr runtime installed to /home/user/.dapr/bin, you may run the following to add it to your path if you want to run daprd directly:
    export PATH=$PATH:/home/user/.dapr/bin
✅  Downloading binaries and setting up components...
✅  Downloaded binaries and completed components set up.
ℹ️  daprd binary has been installed to /home/user/.dapr/bin.
ℹ️  dapr_placement container is running.
ℹ️  dapr_redis container is running.
ℹ️  dapr_zipkin container is running.
ℹ️  Use `docker ps` to check running containers.
✅  Success! Dapr is up and running. To get started, go here: https://aka.ms/dapr-getting-started

Step 3: Verify Dapr version

$ dapr --version
CLI version: 1.12.0
Runtime version: 1.12.2

Step 4: Verify containers are running

dapr の docker がいろいろ作られてます。dapr/zipkin/redisのイメージが作られるようです。

$ docker ps
CONTAINER ID   IMAGE                                 COMMAND                  CREATED         STATUS                   PORTS                                                                                                                                  NAMES
42bd169d7d5d   daprio/dapr:1.12.2                    "./placement"            3 minutes ago   Up 3 minutes             0.0.0.0:50005->50005/tcp, 0.0.0.0:58080->8080/tcp, 0.0.0.0:59090->9090/tcp                                                             dapr_placement
72a8fd271bfe   openzipkin/zipkin                     "start-zipkin"           3 minutes ago   Up 3 minutes (healthy)   9410/tcp, 0.0.0.0:9411->9411/tcp                                                                                                       dapr_zipkin
ff8a4a97c724   redis:6                               "docker-entrypoint.s…"   4 minutes ago   Up 4 minutes             0.0.0.0:6379->6379/tcp                                                                                                                 dapr_redis
3397fe554a04   gcr.io/k8s-minikube/kicbase:v0.0.42   "/usr/local/bin/entr…"   12 days ago     Up 22 hours              127.0.0.1:62695->22/tcp, 127.0.0.1:62696->2376/tcp, 127.0.0.1:62698->5000/tcp, 127.0.0.1:62699->8443/tcp, 127.0.0.1:62697->32443/tcp   minikube

Step 5: Verify components directory has been initialized

$HOME/.dapr/ に何やらいろいろできるみたいなので覗いてみます。

$ ls -ltr $HOME/.dapr/
total 12
-rw-r--r-- 1 user user  187 Nov 29 15:24 config.yaml
drwxrwxrwx 2 user user 4096 Nov 29 15:24 components
drwxrwxrwx 3 user user 4096 Nov 29 15:24 bin
user@dpkatoy:~$ ls -ltr $HOME/.dapr/components
total 8
-rw-r--r-- 1 user user 254 Nov 29 15:24 statestore.yaml
-rw-r--r-- 1 user user 207 Nov 29 15:24 pubsub.yaml
$ ls -ltr $HOME/.dapr/bin
total 215188
drwxr-xr-x 3 user user      4096 Nov 29 15:24 web
-rwxrwxrwx 1 user user  44589056 Nov 29 15:24 dashboard
-rwxrwxrwx 1 user user 175759360 Nov 29 15:24 daprd

ふむ🤔見てもよくわからないので、次に行きましょう。笑


簡単でした👻
次はチュートリアルするよー

Discussion