<p>I had <strong>Istio 1.3.3</strong> gateway and <a href="https://hub.docker.com/r/karthequian/helloworld" rel="nofollow noreferrer">helloworld</a> gateway toward my application service.</p>

<p><strong>Istio Gateway</strong></p>

<pre><code>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
</code></pre>

<p><strong>HelloWorld Gateway</strong></p>

<pre><code>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
</code></pre>

<p><strong>HelloWorld.yaml</strong></p>

<pre><code>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
</code></pre>

<p>When I tried to access the application from Istio gateway using <code>localhost:15033</code>, working with different port and docker images are working fine, but <a href="https://hub.docker.com/r/karthequian/helloworld" rel="nofollow noreferrer">this docker image</a> that used nginx doesn't work well.</p>

<p>I got an error when access to <code>localhost:15033</code></p>

<blockquote>
  <p>upstream connect error or disconnect/reset before headers. reset reason: connection termination</p>
</blockquote>

<hr>

<p><strong>Informations</strong></p>

<p>Kubernetes started and installed from Mac Desktop Docker Application. Context was desktop-docker.</p>

<ol>
<li>kubectl version</li>
</ol>

<pre><code>Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.6", GitCommit:"96fac5cd13a5dc064f7d9f4f23030a6aeface6cc", GitTreeState:"clean", BuildDate:"2019-08-19T11:13:49Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.6", GitCommit:"96fac5cd13a5dc064f7d9f4f23030a6aeface6cc", GitTreeState:"clean", BuildDate:"2019-08-19T11:05:16Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}
</code></pre>

<ol start="2">
<li>kubectl cluster-info</li>
</ol>

<pre><code>Kubernetes master is running at https://kubernetes.docker.internal:6443
KubeDNS is running at https://kubernetes.docker.internal:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
</code></pre>

<ol start="3">
<li>kubectl cluster-info dump > clusterInfoDump.txt</li>
</ol>

<p><a href="https://justpaste.it/5n1op" rel="nofollow noreferrer">https://justpaste.it/5n1op</a></p>

<ol start="4">
<li>istioctl version</li>
</ol>

<pre><code>client version: 1.3.3
control plane version: 1.3.3
</code></pre>

Abel
<p>In Your HelloWorld.yaml You are missing <code>targetPort</code> and this is why nginx is unreachable.</p>

<p>This is how it should look:</p>

<pre><code>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
</code></pre>
