发布时间:2023-02-03 文章分类:编程知识 投稿人:王小丽 字号: 默认 | | 超大 打印

1 简介

我们之前使用了dapr的本地托管模式,但在生产中我们一般使用Kubernetes托管,本文介绍如何在GKE(GCP Kubernetes)安装dapr。

相关文章:

2 安装GKE

我们直接在网页上安装GKE,我们安装的是Autopilot模式的GKE,如下:

在GCP的Kubernetes上安装dapr

点击创建,等一段时间后就会创建成功了。

检查 GKE状态

需要安装以下gcloud插件:

$ gcloud components install gke-gcloud-auth-plugin

获取权限让kubectl可以访问:

$ gcloud container clusters get-credentials pkslow-autopilot --zone us-west1

查看node节点,说明正常启动了:

$ kubectl get nodes
NAME                                              STATUS   ROLES    AGE   VERSION
gk3-pkslow-autopilot-default-pool-1bb48cfc-6jzc   Ready    <none>   64m   v1.23.8-gke.1900
gk3-pkslow-autopilot-default-pool-33b02029-zz1d   Ready    <none>   64m   v1.23.8-gke.1900

安装dapr

创建namespace:

$ kubectl create ns pkslow-dapr
namespace/pkslow-dapr created

我们用helm工具来安装,先添加仓库:

$ helm repo add dapr https://dapr.github.io/helm-charts/
"dapr" has been added to your repositories
$ helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "dapr" chart repository
...Successfully got an update from the "stable" chart repository
...Successfully got an update from the "k8ssandra" chart repository
...Successfully got an update from the "azure" chart repository
Update Complete. ⎈ Happy Helming!⎈ 

通过下面命令安装dapr如下:

$ helm install dapr dapr/dapr --namespace pkslow-dapr
NAME: dapr
LAST DEPLOYED: Wed Nov  9 22:16:51 2022
NAMESPACE: pkslow-dapr
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Thank you for installing Dapr: High-performance, lightweight serverless runtime for cloud and edge
Your release is named dapr.
To get started with Dapr, we recommend using our quickstarts:
https://github.com/dapr/quickstarts
For more information on running Dapr, visit:
https://dapr.io

过一段时间后,Pod启动完成,然后查看状态如下:

$ kubectl get pods -n pkslow-dapr
NAME                                     READY   STATUS    RESTARTS   AGE
dapr-dashboard-68d9d6c58-7nwqm           1/1     Running   0          2m58s
dapr-operator-5d44bd648d-6wlbf           1/1     Running   0          2m58s
dapr-placement-server-0                  1/1     Running   0          2m57s
dapr-sentry-67d76bc57-tp67f              1/1     Running   0          2m58s
dapr-sidecar-injector-84f85f5699-scz4c   1/1     Running   0          2m58s

查看dapr的Dashboard:

$ dapr dashboard -k -n pkslow-dapr
W1109 22:21:50.051562   52857 gcp.go:120] WARNING: the gcp auth plugin is deprecated in v1.22+, unavailable in v1.25+; use gcloud instead.
To learn more, consult https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke
ℹ️  Dapr dashboard found in namespace:	pkslow-dapr
ℹ️  Dapr dashboard available at:	http://localhost:8080

打开网页:

在GCP的Kubernetes上安装dapr

控制面板:

在GCP的Kubernetes上安装dapr

总结

至此,我们在GKE成功地安装了dapr。

References:

用Helm部署Kubernetes应用,支持多环境部署与版本回滚

GCP常用命令(gcloud、gsutil)

通过gcloud创建Google Kubernetes Engine(GKE)并通过kubectl访问