Docker Istio网关重定向到HTML nginx图像';行不通

Docker Istio网关重定向到HTML nginx图像';行不通,docker,nginx,kubernetes,istio,Docker,Nginx,Kubernetes,Istio,我有Istio 1.3.3网关和我的应用程序服务网关 Istio网关 apiVersion: v1 kind: Service metadata: labels: app: istio-ingressgateway chart: gateways-1.0.0 heritage: Tiller istio: ingressgateway release: RELEASE-NAME name: istio-ingressgateway namesp

我有Istio 1.3.3网关和我的应用程序服务网关

Istio网关

apiVersion: v1
kind: Service
metadata:
  labels:
    app: istio-ingressgateway
    chart: gateways-1.0.0
    heritage: Tiller
    istio: ingressgateway
    release: RELEASE-NAME
  name: istio-ingressgateway
  namespace: istio-system
spec:
  externalTrafficPolicy: Cluster
  ports:
  - name: http2
    nodePort: 31380
    port: 80
    protocol: TCP
    targetPort: 80
  - name: https
    nodePort: 31390
    port: 443
    protocol: TCP
    targetPort: 443
  - name: tcp
    nodePort: 31400
    port: 31400
    protocol: TCP
    targetPort: 31400
  - name: tcp-pilot-grpc-tls
    nodePort: 32565
    port: 15011
    protocol: TCP
    targetPort: 15011
  - name: tcp-citadel-grpc-tls
    nodePort: 32352
    port: 8060
    protocol: TCP
    targetPort: 8060
  - name: http2-helloworld
    nodePort: 31750
    port: 15033
    protocol: TCP
    targetPort: 15033
  selector:
    app: istio-ingressgateway
    istio: ingressgateway
  type: LoadBalancer
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: helloworld-gateway
spec:
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 15033
      name: http2-helloworld
      protocol: HTTP
    hosts:
    - "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: helloworld
spec:
  hosts:
  - "*"
  gateways:
  - helloworld-gateway
  http:
  - match:
    - port: 15033
    route:
    - destination:
        host: helloworld
        port:
          number: 5000
HelloWorld网关

apiVersion: v1
kind: Service
metadata:
  labels:
    app: istio-ingressgateway
    chart: gateways-1.0.0
    heritage: Tiller
    istio: ingressgateway
    release: RELEASE-NAME
  name: istio-ingressgateway
  namespace: istio-system
spec:
  externalTrafficPolicy: Cluster
  ports:
  - name: http2
    nodePort: 31380
    port: 80
    protocol: TCP
    targetPort: 80
  - name: https
    nodePort: 31390
    port: 443
    protocol: TCP
    targetPort: 443
  - name: tcp
    nodePort: 31400
    port: 31400
    protocol: TCP
    targetPort: 31400
  - name: tcp-pilot-grpc-tls
    nodePort: 32565
    port: 15011
    protocol: TCP
    targetPort: 15011
  - name: tcp-citadel-grpc-tls
    nodePort: 32352
    port: 8060
    protocol: TCP
    targetPort: 8060
  - name: http2-helloworld
    nodePort: 31750
    port: 15033
    protocol: TCP
    targetPort: 15033
  selector:
    app: istio-ingressgateway
    istio: ingressgateway
  type: LoadBalancer
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: helloworld-gateway
spec:
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 15033
      name: http2-helloworld
      protocol: HTTP
    hosts:
    - "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: helloworld
spec:
  hosts:
  - "*"
  gateways:
  - helloworld-gateway
  http:
  - match:
    - port: 15033
    route:
    - destination:
        host: helloworld
        port:
          number: 5000
HelloWorld.yaml

apiVersion: v1
kind: Service
metadata:
  name: helloworld
  labels:
    app: helloworld
spec:
  ports:
  - port: 5000
    name: http
  selector:
    app: helloworld
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: helloworld-v1
  labels:
    version: v1
spec:
  replicas: 2
  selector:
    matchLabels:
      app: helloworld
      version: v1
  template:
    metadata:
      labels:
        app: helloworld
        version: v1
    spec:
      containers:

      - name: helloworld
        image: karthequian/helloworld:latest
        resources:
          requests:
            cpu: "100m"
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 80
当我尝试使用
localhost:15033
从Istio网关访问应用程序时,使用不同的端口和docker映像可以正常工作,但使用的nginx不起作用

访问
localhost:15033

上游连接错误或在收割台之前断开/重置。重置原因:连接终止


信息

Kubernetes从Mac桌面Docker应用程序启动并安装。上下文是桌面docker

  • kubectl版本
  • kubectl集群信息
  • kubectl群集信息转储>ClusterInfo转储.txt
  • istioctl版本

  • 在HelloWorld.yaml中,缺少
    targetPort
    ,这就是nginx无法访问的原因

    它应该是这样的:

    apiVersion: v1
    kind: Service
    metadata:
      name: helloworld
      labels:
        app: helloworld
    spec:
      ports:
      - port: 5000
        name: http
        targetPort: 80
      selector:
        app: helloworld
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: helloworld-v1
      labels:
        version: v1
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: helloworld
          version: v1
      template:
        metadata:
          labels:
            app: helloworld
            version: v1
        spec:
          containers:
    
          - name: helloworld
            image: karthequian/helloworld:latest
            resources:
              requests:
                cpu: "100m"
            imagePullPolicy: IfNotPresent
            ports:
            - containerPort: 80
    

    您好@Henry Chozo您能验证此服务是否启用了mTLS吗@PiotrMalec不,我没有使用目的地规则。你能给我提供你的集群环境/平台信息吗。安装方法和kubernetes版本?@PiotrMalec信息已更新。
    apiVersion: v1
    kind: Service
    metadata:
      name: helloworld
      labels:
        app: helloworld
    spec:
      ports:
      - port: 5000
        name: http
        targetPort: 80
      selector:
        app: helloworld
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: helloworld-v1
      labels:
        version: v1
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: helloworld
          version: v1
      template:
        metadata:
          labels:
            app: helloworld
            version: v1
        spec:
          containers:
    
          - name: helloworld
            image: karthequian/helloworld:latest
            resources:
              requests:
                cpu: "100m"
            imagePullPolicy: IfNotPresent
            ports:
            - containerPort: 80