The micro service Demo with Dapr.
- apigateway: envoy
- sample-server: grpc server with dapr handler
- iam: iam grpc server and impl envoy ext-authz
- kc-server: http server
- cr(container-registry): grpc server
开发聚焦于业务实现,dapr 完成以下部分
- 服务发现
- 服务 mtls 认证
- 服务调用重试、限流
- 服务访问策略
- 状态管理
- 消息系统
- 可观测性
- install go
- brew install protobuf
- brew install envoy
- go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
- go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
- go install github.com/envoyproxy/protoc-gen-validate@v0.16.3
- go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@latest
- k8s cluster with StorageClass
- install helm
wget https://get.helm.sh/helm-v3.10.1-linux-amd64.tar.gz
- install dapr
wget https://github.com/dapr/cli/releases/download/v1.9.1/dapr_linux_amd64.tar.gz
- install dapr runtime
dapr init -k --enable-ha=true
- install zipkin
kubectl create deployment zipkin --image openzipkin/zipkin
kubectl expose deployment zipkin --type ClusterIP --port 9411
helm repo add openebs https://openebs.github.io/charts
helm repo update
mkdir -pv /data
helm install openebs openebs/openebs -n openebs --create-namespace --set localprovisioner.basePath=/data
kubectl patch storageclass openebs-hostpath -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
helm install redis bitnami/redis --set image.tag=6.2
kubectl create cm gateway-config --from-file=envoy.yaml=deploy/envoy.yaml
kubectl create cm gateway-proto --from-file=proto.pb=proto/proto.pb
kubectl apply -f deploy/
All Request will be deny except with Bearer Token hanamichi
or spike
- call dapr HTTP
echo
handler without token
Request:
curl -X POST \
'192.168.234.3:31484/s/echo' \
--header 'Accept: */*' \
--header 'Authorization: Bearer spike2' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "value2"
}'
Respond:
http status: 401
body: PERMISSION_DENIED
- call dapr HTTP
echo
handler without token
Request:
curl -X POST \
'192.168.234.3:31484/s/echo' \
--header 'Accept: */*' \
--header 'Authorization: Bearer spike' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "value2"
}'
Respond:
http status: 200
body:
{
"name": "value2"
}