【发布时间】:2020-11-19 01:22:16
【问题描述】:
我的测试环境集群有以下配置:
全局网格策略(作为集群设置的一部分由我们的组织安装):kubectl describe MeshPolicy default 的输出
Name: default
Namespace:
Labels: operator.istio.io/component=Pilot
operator.istio.io/managed=Reconcile
operator.istio.io/version=1.5.6
release=istio
Annotations: kubectl.kubernetes.io/last-applied-configuration:
{"apiVersion":"authentication.istio.io/v1alpha1","kind":"MeshPolicy","metadata":{"annotations":{},"labels":{"operator.istio.io/component":...
API Version: authentication.istio.io/v1alpha1
Kind: MeshPolicy
Metadata:
Creation Timestamp: 2020-07-23T17:41:55Z
Generation: 1
Resource Version: 1088966
Self Link: /apis/authentication.istio.io/v1alpha1/meshpolicies/default
UID: d3a416fa-8733-4d12-9d97-b0bb4383c479
Spec:
Peers:
Mtls:
Events: <none>
我相信上述配置可以让服务以 mTls 模式接收连接。
DestinationRule : kubectl describe DestinationRule commerce-mesh-port -n istio-system 的输出
Name: commerce-mesh-port
Namespace: istio-system
Labels: <none>
Annotations: kubectl.kubernetes.io/last-applied-configuration:
{"apiVersion":"networking.istio.io/v1alpha3","kind":"DestinationRule","metadata":{"annotations":{},"name":"commerce-mesh-port","namespace"...
API Version: networking.istio.io/v1beta1
Kind: DestinationRule
Metadata:
Creation Timestamp: 2020-07-23T17:41:59Z
Generation: 1
Resource Version: 33879
Self Link: /apis/networking.istio.io/v1beta1/namespaces/istio-system/destinationrules/commerce-mesh-port
UID: 4ef0d49a-88d9-4b40-bb62-7879c500240a
Spec:
Host: *
Ports:
Name: commerce-mesh-port
Number: 16443
Protocol: TLS
Traffic Policy:
Tls:
Mode: ISTIO_MUTUAL
Events: <none>
Istio 入口网关:
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: finrpt-gateway
namespace: finrpt
spec:
selector:
istio: ingressgateway # use Istio's default ingress gateway
servers:
- port:
name: https
number: 443
protocol: https
tls:
mode: SIMPLE
serverCertificate: /etc/istio/ingressgateway-certs/tls.crt
privateKey: /etc/istio/ingressgateway-certs/tls.key
hosts:
- "*"
- port:
name: http
number: 80
protocol: http
tls:
httpsRedirect: true
hosts:
- "*"
我创建了一个用于 TLS 的密钥,并使用它来终止网关上的 TLS 流量(在 SIMPLE 模式下配置)
接下来,我在同一个命名空间中配置了我的 VirtualService 并为 HTTP 进行了 URL 匹配:
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: finrpt-virtualservice
namespace: finrpt
spec:
hosts:
- "*"
gateways:
- finrpt-gateway
http:
- match:
- queryParams:
target:
exact: "commercialprocessor"
ignoreUriCase: true
route:
- destination:
host: finrpt-commercialprocessor
port:
number: 8118
Service CommercialProcessor (ClusterIP) 预计 HTTP/8118 上的流量。
通过上述设置,当我浏览到我的 Ingress-Gateway 的外部 IP 时,首先我收到一个证书错误(预计我正在使用自签名进行测试),然后继续我收到 HTTP 错误 503 .
我无法在网关中找到任何有用的日志,我想知道网关是否无法以纯文本方式与我的 VirtualService 通信(TLS 终止)并且它需要 https,但我已将其设置为 http? 非常感谢任何帮助,我对 Istio 还很陌生,我想我可能在这里遗漏了一些幼稚的东西。
我的期望是:我应该能够使用 https 访问网关,网关执行终止并将未加密的流量转发到仅基于 URL 正则表达式匹配的 HTTP 端口上的 VirtualService 中配置的目标(我必须保持 URL 匹配部分不变)。
【问题讨论】:
-
网关看起来不错,如果我正确理解文档,那么
ignoreUriCase: true将无法使用 queryParamas,只能使用 uri。我不知道那个 commerce-mesh-port 目的地规则是干什么用的?您能否尝试为您的虚拟服务添加destination rule 和trafficPolicy: tls: mode: SIMPLE,如documentation 中所述? -
感谢@jt97 的回复。我确实尝试为默认命名空间中的所有主机创建一个模式为 SIMPLE 的新目标规则,但没有奏效。我什至尝试过禁用,但它也不起作用。我认为 commerce-mesh-port 必须与 kube api 服务器联系,因为它可能来自端口号 16443,但不确定。最后,我删除了任何与 ISTIO_MUTUAL 相关的 ServiceEntry/DestinationRule 并再次尝试但没有运气:( 仍然收到 503 错误。
-
你说的ServiceEntry,是指虚拟服务?或者您是否使用服务入口并且您的应用程序不在网格中?如here 所述,您的服务名称是否正确?您可以尝试先部署目标规则,然后再部署虚拟服务吗?您是否使用 istio-injection=enabled 标记命名空间?您可以尝试安装bookinfo app 并检查它是否有效吗?
-
我看到@Jakub 发布的答案对您有所帮助,请考虑支持/接受它,以便其他用户可以看到它很有用。请参考What should I do when someone answers my question?
标签: http kubernetes istio azure-aks