假设 Kubernetes 和 Dapr 已正确设置
概要: Dapr Sub/Pub 应用程序可根据需要与 ONE pod 一起使用。
我有以下 K8s Deployment
(一个简单的 Springboot 应用程序)
apiVersion: apps/v1
kind: Deployment
metadata:
name: webapp
spec:
replicas: 1
selector:
matchLabels:
app: webapp
template:
metadata:
labels:
app: webapp
annotations:
dapr.io/enabled: "true"
dapr.io/app-id: "webapp"
dapr.io/app-port: "8080"
spec:
containers:
- name: webapp
image: webapp:1.0.0
ports:
- containerPort: 8080
我有以下Redis
Component
状态
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: webapp
namespace: default
spec:
type: pubsub.redis
version: v1
metadata:
- name: redisHost
value: redis-master.default.svc.cluster.local.:6379
- name: redisPassword
value: "xxxx"
- name: consumerID
value: "myGroup"
- name: enableTLS
value: "false"
Dapr Sub/Pub 概览
参考:https ://docs.dapr.io/developing-applications/building-blocks/pubsub/pubsub-overview/
问题:扩展此应用程序(即kubectl scale deploy webapp --replicas 5
)仅允许一个订阅者同时接收消息。这是因为“dapr.io/app-id”在复制时是相同的。
问题:如何扩展 Dapr Sub/Pub 应用程序(使用Deployment
注解进行边车注入)并允许每个扩展的 pod 接收相同的消息?