jxlwqq / blog-microservices

A blog microservices written in Golang, which can be deployed in an Istio-enabled kubernetes cluster.
MIT License
189 stars 40 forks source link

Istio 虚拟服务和 CORS #6

Open jxlwqq opened 2 years ago

jxlwqq commented 2 years ago

根据 GitHub 项目中反馈的问题,gRPC网关不直接支持跨源资源共享(Cross-Origin Resource Sharing, CORS)策略。因此,我使用虚拟服务资源的 CorsPolicy 配置将CORS的职责转移给了Istio。这使得CORS比硬编码到服务代码中 (如使用 https://github.com/rs/cors) 更容易管理。

jxlwqq commented 2 years ago

https://github.com/jxlwqq/blog-microservices/blob/ec61e38fa9baa67a717958b816735ea5f311212f/deployments/istio.yaml#L16-L54

DianWoung commented 2 years ago

运行make kube-deploy时allMethods这里会报Error from server: error when creating "deployments/istio.yaml": admission webhook "validation.istio.io" denied the request: configuration is invalid: "*" is not a supported HTTP method,需要指定请求方式才行

jxlwqq commented 2 years ago

运行make kube-deploy时allMethods这里会报Error from server: error when creating "deployments/istio.yaml": admission webhook "validation.istio.io" denied the request: configuration is invalid: "*" is not a supported HTTP method,需要指定请求方式才行

你的 istio version 是多少?

DianWoung commented 2 years ago

1.13版本

jxlwqq commented 2 years ago

运行make kube-deploy时allMethods这里会报Error from server: error when creating "deployments/istio.yaml": admission webhook "validation.istio.io" denied the request: configuration is invalid: "*" is not a supported HTTP method,需要指定请求方式才行

已修复,非常感谢

https://github.com/jxlwqq/blog-microservices/commit/ec61e38fa9baa67a717958b816735ea5f311212f

DianWoung commented 2 years ago

-db的service都正常,-server的除了dtm之外,都报同一个错误,是环境有问题吗

Failed to pull image "blog/blog-server:latest": rpc error: code = Unknown desc = Error response from daemon: pull access denied for blog/blog-server, repository does not exist or may require 'docker login': denied: requested access to the resource is denied 
jxlwqq commented 2 years ago

需要在本地构建镜像

# build docker images
make docker-build
# deploy all services
make kube-deploy