Kubernetes 内部的 Istio CORS 和 SSL 问题



我一直在砸我的头,我不知道这是一个错误还是只是配置错误。我的情况如下:

在我的集群中,我有命名空间"testing",它有 2 个部署:

  1. 前端
  2. 后端

服务业:

  1. 前端服务.本地
  2. back-end-service.local

两者都有其服务正常工作,并且 ALB 配置为从浏览器访问。

  1. https://front.example.com
  2. https://back.example.com

在集群内部,从前端,我可以用变量指向后端 https://back.example.com,一切都按预期工作。

但是,我被要求在集群内部进行通信,所以我的第一次尝试是这次从前端指向后端服务。

尝试指向:https://back-end-service.local 并收到此错误:

原因:CORS 请求未成功

猜测这是因为 TLS,我在命名空间中部署了 Istio,并在 STRICT 模式下启用了双向 TLS。打开Kiali后,我确实看到加密通信正常工作,但是,我仍然收到相同的错误。

我做的测试:

如果我登录到前端 pod 并尝试进行卷曲 https://back.example.com,我会从我的 API 得到积极的响应。

如果我做一个卷曲 https://back-end-service.local,我会得到卷曲:(35( SSL 例程:SSL23_GET_SERVER_HELLO:未知协议。

简而言之,我可以在集群外部与后端通信,然后返回,但是如果我尝试在内部服务之间进行通信,它会失败并出现 CORS 和 SSL 错误。

我的配置:

kind: PeerAuthentication
apiVersion: security.istio.io/v1beta1
metadata:
name: default
namespace: testing
selfLink: >-
/apis/security.istio.io/v1beta1/namespaces/production/peerauthentications/default     
resourceVersion: '7291'
generation: 1
creationTimestamp: '2020-06-06T00:22:24Z'
annotations:
kubectl.kubernetes.io/last-applied-configuration: >
{"apiVersion":"security.istio.io/v1beta1","kind":"PeerAuthentication","metadata":{"annotations":{},"name":"default","namespace":"testing"},"spec":{"mtls":{"mode":"STRICT"}}}
spec:
selector: ~
mtls:
mode: STRICT
portLevelMtls: ~

后端服务:

kind: Service
apiVersion: v1
metadata:
name: back-end-service
namespace: testing
selfLink: /api/v1/namespaces/testing/services/back-end-service
uid: dccf1b
resourceVersion: '7520501'
creationTimestamp: '2020-05-14T21:48:54Z'
labels:
app: back-end
annotations:
kubectl.kubernetes.io/last-applied-configuration: >
{"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app":"back-end"},"name":"back-end-service","namespace":"testing"},"spec":{"ports":[{"name":"http","port":3001,"targetPort":3001}],"selector":{"app":"back-end"}}}
finalizers:
- service.kubernetes.io/load-balancer-cleanup
spec:
ports:
- name: https
protocol: TCP
port: 3001
targetPort: 3001
nodePort: 30742
selector:
app: back-end
clusterIP: 192.168.1.1
type: LoadBalancer
sessionAffinity: None
externalTrafficPolicy: Cluster

我试图将名称更改为HTTP和服务HTTPS,但它超出了这个范围。任何帮助将不胜感激!

您可以尝试使用端口 3001 代替端口 443 吗?端口 443 上可能没有 https,因此 SSL 错误。

最新更新