Istio tls 端口 443 给出 503 服务不可用

Istio tls port 443 gives 503 Service Unavailable

我是 运行 kubernetes Azure AKS 集群上的服务。

Istio-version: 1.3.2

我的服务正在侦听端口 80 和 443:

NAME               TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)          AGE
hello-kubernetes   ClusterIP   10.0.43.233   <none>        80/TCP,443/TCP   28h

还有 istio-gateway.yaml 文件如下所示:

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: my-gateway
spec:
  selector:
    istio: ingressgateway 
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"
    #tls:
      #httpsRedirect: true
  - port:
      number: 443
      name: https
      protocol: HTTPS
    hosts:
    - "*"
    tls:
      mode: SIMPLE
      credentialName: "mycert" # must be the same as secret
      privateKey: sds
      serverCertificate: sds
      #serverCertificate: /etc/istio/ingressgateway-certs/tls.crt
      #privateKey: /etc/istio/ingressgateway-certs/tls.key

秘密是通过以下命令创建的——我有一个自定义证书,我已经上传到集群上:

kubectl create -n istio-system secret generic mycert \
  --from-file=key=/home/user/istio-1.3.2/ssl/myprivate.key \
  --from-file=cert=/home/user/istio-1.3.2/ssl/mycert.pem

mycert.pem 文件包括证书密钥和中间密钥。

VirtualService 文件如下:

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: hello-kubernetes
spec:
  hosts:
  - "mydomain.com"
  gateways:
  - my-gateway
  http:
  - match:
    - uri:
        prefix: /hello-k8s
    route:
    - destination:
        host: hello-kubernetes

如果我用 http 卷曲它,它会给我 200 OK 响应,但是当我用 https 端口卷曲它时,它会给出 HTTP/1.1 503 服务不可用。

浏览器上的错误信息是: NET::ERR_CERT_AUTHORITY_INVALID

知道它缺少什么吗?

通过添加修复错误:

port:
   number: 80

在虚拟服务文件的目标部分。