安装Dapr的CLI
在安装Dapr runtime之前需要先安装Dapr的CLI。有两个原因,第一,如果你以后不是用Helm来安装Dapr的话,需要用Dapr CLI来执行dapr init。即使你用Helm安装,以后查看Dapr系统状态的时候还是要用到Dapr CLI,比如查看Runtime的状态(dapr status -k),查看Components状态(dapr components -k),查看Configurations状态(dapr configurations -k),甚至启动Dashboard的时候还是要执行(dapr dashboard -k)。你可以在很多OS上安装Dapr CLI,比如Windows,Linux,Mac OS,我用的是Windows10系统,可以选择在Windows上直接装,也可以在WSL(Windows Subsystem for Linux)上装,这里选择在WSL上安装(没有WSL的话在windows商店里选一个免费的Linux装上。我选的是Ubuntu)。参考官方文档How-To: Install Dapr CLI,在Ubuntu里执行:
$ wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash
Your system is linux_amd64
Installing Dapr CLI...
Getting the latest Dapr CLI...
Installing v0.11.0 Dapr CLI...
Downloading https://github.com/dapr/cli/releases/download/v0.11.0/dapr_linux_amd64.tar.gz ...
[sudo] password for ubuntu:
dapr installed into /usr/local/bin successfully.
CLI version: 0.11.0
Runtime version: n/a
To get started with Dapr, please visit https://docs.dapr.io/getting-started/
安装完成。看看版本号:
$ sudo dapr --version
CLI version: 0.11.0
Runtime version: n/a
目前最新的是0.11.0.Runtime因为还没装,所以显示n/a。
CLI安装完毕。接下来安装Runtime。
安装Dapr的Runtime
这里有两种选择,一个是Standalone mode,一个是Kubernetes mode。我们两个都试一下。
安装Docker Engine
Dapr Runtime安装的前提条件是要先安装Docker。不然安装Dapr的时候会报"could not connect to Docker. Docker may not be installed or running"的错。这里参考Docker的官方文档Install Docker Engine on Ubuntu来安装Docker Engine。
$ sudo apt-get update
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo apt-key fingerprint 0EBFCD88
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
安装完成。把docker的service启动:
$ sudo service docker start
看看service是否启动:
$ sudo service docker status
* Docker is running
OK,Docker Engine安装完成。
安装Standalone版的Dapr Runtime
用dapr init来安装单机版,可以指定版本号。目前最新的是1.0.0-rc.2。
$ sudo dapr init --runtime-version=1.0.0-rc.2
⌛ Making the jump to hyperspace...
←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑↗ Downloading binaries and setting up components...
Dapr runtime installed to /root/.dapr/bin, you may run the following to add it to your path if you want to run daprd directly:
export PATH=$PATH:/root/.dapr/bin
→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←↑→↓←✅ Downloaded binaries and completed components set up.
ℹ️ daprd binary has been installed to /root/.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
export PATH=$PATH:/root/.dapr/bin
完成。看看都装了什么东西。
$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
293b479ed26c openzipkin/zipkin "start-zipkin" 5 minutes ago Up 4 minutes (healthy) 9410/tcp, 0.0.0.0:9411->9411/tcp dapr_zipkin
a07696221fd2 daprio/dapr "./placement" 5 minutes ago Up 4 minutes 0.0.0.0:50005->50005/tcp dapr_placement
c475c415332b redis "docker-entrypoint.s…" 6 minutes ago Up 6 minutes 0.0.0.0:6379->6379/tcp dapr_redis
跑起来三个Container。一个dapr_zipkin,一个dapr_placement,一个dapr_redis。
看看版本号:
$ sudo dapr --version
CLI version: 0.11.0
Runtime version: 1.0.0-rc.2
至此单机版的Dapr Runtime安装完成。
dapr list一下看看,什么也没有。因为我们还没有启动App。
安装Kubernetes版的Dapr Runtime
安装之前需要先有Kubernetes环境,minikube,AWS托管的EKS,Azure托管的AKS,GCP托管的GKE等等。这里选择在本地安装minikube。
参考官方文档
$ curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
$ sudo install minikube-linux-amd64 /usr/local/bin/minikube
看看版本:
$ minikube version
minikube version: v1.16.0
commit: 9f1e482427589ff8451c4723b6ba53bb9742fbb1
先执行
$ sudo usermod -aG docker $USER && newgrp docker
不然minikube启动的时候会报错。然后启动minikube环境:
$ minikube start
标签:入门教程,sudo,之二,Dapr,dapr,minikube,docker,安装
来源: https://www.cnblogs.com/thrillcattle/p/14191058.html