<p>I have a kubernetes cluster on GCP made of two nodes. I have pod -> mycha-deploy, with service -> mycha-svc, also I have pod nginx-controller with service nginx-svc. When I try to curl  into the pods or services ips I keep getting: port 80 conection refused. When I browse into the master ip I don't get anything. Is there something I am missing in the configuration. Thank you.</p>

<pre><code># mycha-deploy
apiVersion: apps/v1
kind:  Deployment
metadata:
  name: mycha-deploy
  labels:
    app: mycha-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mycha-app
  template:
    metadata:
      labels:
        app: mycha-app
    spec:
      containers:
        - name: mycha-container
          image: us.gcr.io/########/mycha-frontend_kubernetes_rrk8s
          ports:
          - containerPort: 80

#mycha-svc
apiVersion: v1
kind: Service
metadata:
  name: mycha-svc
  labels: 
    app: mycha-app
spec:
  selector:
    app: mycha-app
  ports:
  - port: 80
    targetPort: 80
    protocol: TCP
    name: http

#nginx-controller
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-controller
spec:
  replicas: 1
  selector:
    matchLabels:
      name: nginx-ingress
  template:
    metadata:
      labels:
        name: nginx-ingress
    spec:
      containers:
        - name: nginx-ingress-controller
          image: quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.27.0
          args:
            - /nginx-ingress-controller
            - --configmap=$(POD_NAMESPACE)/nginx-configuration
          env:
            - name: POD_NAME
              valueFrom: 
                fieldRef:
                  fieldPath: metadata.name
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          ports:
          - name: http
            containerPort: 80
          - name: https
            containerPort: 443

#nignx-svc
apiVersion: v1
kind: Service
metadata:
  name: nginx-ingress
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
spec:
  type: NodePort
  ports: 
  - port: 80
    targetPort: 80
    protocol: TCP
    name: http
  - port: 443
    targetPort: 443
    protocol: TCP
    name: https
  selector:
    name: nginx-ingress


##nginx-resource
apiVersion: extensions/v1beta1
kind: Ingress
metadata: 
  name: mycha-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
  - http:
      paths:
        - path: /
          backend:
            serviceName: mycha-svc
            servicePort: 80

-----

kubectl describe svc nginx-ingress
Name:                     nginx-ingress
Namespace:                default
Labels:                   app.kubernetes.io/name=ingress-nginx
                          app.kubernetes.io/part-of=ingress-nginx
Annotations:              &lt;none&gt;
Selector:                 name=nginx-ingress
Type:                     NodePort
IP:                       10.107.186.83
Port:                     http  80/TCP
TargetPort:               80/TCP
NodePort:                 http  32606/TCP
Endpoints:                10.244.1.3:80
Port:                     https  443/TCP
TargetPort:               443/TCP
NodePort:                 https  31481/TCP
Endpoints:                10.244.1.3:443
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   &lt;none&gt;

-------

kubectl get pods,svc
NAME                                    READY   STATUS    RESTARTS   AGE
pod/mycha-deploy-5f9b6f5c46-jjdhq       1/1     Running   0          76m
pod/nginx-controller-5c45cf6d5c-dpp44   1/1     Running   0          60m

NAME                    TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                      AGE
service/kubernetes      ClusterIP   10.96.0.1       &lt;none&gt;        443/TCP                      100m
service/mycha-svc       ClusterIP   10.103.188.25   &lt;none&gt;        80/TCP                       68m
service/nginx-ingress   NodePort    10.107.186.83   &lt;none&gt;        80:32606/TCP,443:31481/TCP   51m



------

sudo lsof -i -P -n | grep LISTEN
systemd-r   890 systemd-resolve   13u  IPv4     16536      0t0  TCP 127.0.0.53:53 (LISTEN)
splunkd    1111            root    4u  IPv4     25377      0t0  TCP *:8089 (LISTEN)
sshd       1842            root    3u  IPv4     23916      0t0  TCP *:22 (LISTEN)
sshd       1842            root    4u  IPv6     23931      0t0  TCP *:22 (LISTEN)
kube-cont 22737            root    5u  IPv6 116157110      0t0  TCP *:10252 (LISTEN)
kube-cont 22737            root    6u  IPv4 116157116      0t0  TCP 127.0.0.1:10257 (LISTEN)
kube-prox 23291            root    8u  IPv6 116256894      0t0  TCP *:31481 (LISTEN)
kube-prox 23291            root   11u  IPv6 116256895      0t0  TCP *:32606 (LISTEN)
kube-prox 23291            root   16u  IPv6 116164057      0t0  TCP *:10256 (LISTEN)
kube-prox 23291            root   17u  IPv4 116164061      0t0  TCP 127.0.0.1:10249 (LISTEN)
etcd      23380            root    3u  IPv4 116158620      0t0  TCP 10.242.6.2:2380 (LISTEN)
etcd      23380            root    5u  IPv4 116158624      0t0  TCP 10.242.6.2:2379 (LISTEN)
etcd      23380            root    6u  IPv4 116158625      0t0  TCP 127.0.0.1:2379 (LISTEN)
etcd      23380            root   11u  IPv4 116157996      0t0  TCP 127.0.0.1:2381 (LISTEN)
kube-sche 23803            root    5u  IPv6 116159474      0t0  TCP *:10251 (LISTEN)
kube-sche 23803            root    6u  IPv4 116159480      0t0  TCP 127.0.0.1:10259 (LISTEN)
kube-apis 24180            root    5u  IPv6 116163385      0t0  TCP *:6443 (LISTEN)
node      27844     robertorios   20u  IPv4 116024875      0t0  TCP 127.0.0.1:38509 (LISTEN)
kubelet   30601            root   10u  IPv4 116038855      0t0  TCP 127.0.0.1:33119 (LISTEN)
kubelet   30601            root   17u  IPv6 116038993      0t0  TCP *:10250 (LISTEN)
kubelet   30601            root   31u  IPv4 116038997      0t0  TCP 127.0.0.1:10248 (LISTEN)
</code></pre>

<p>Thank you.</p>

Roberto Rios
<p>On GKE you can use two types of Ingress. One is <code>Nginx Ingress</code> which you probably wanted to use based on annotation <code>kubernetes.io/ingress.class: &quot;nginx&quot;</code>. Second one is GKE Ingress.</p>
<p><strong>1. GKE Ingress</strong></p>
<p>When you want to use <code>GKE Ingress</code> you need to specify your service as <code>NodePort</code> and apply <code>Ingress</code>. Based on your YAMLs, I've reproduced it.</p>
<p>As you used your own image, Ive used nginx image.</p>
<pre><code>apiVersion: apps/v1
kind:  Deployment
metadata:
  name: mycha-deploy
  labels:
    app: mycha-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mycha-app
  template:
    metadata:
      labels:
        app: mycha-app
    spec:
      containers:
        - name: mycha-container
          image: nginx
          ports:
          - containerPort: 80

---
#added type: Nodeport
apiVersion: v1
kind: Service
metadata:
  name: mycha-svc
  labels: 
    app: mycha-app
spec:
  type: NodePort 
  selector:
    app: mycha-app
  ports:
  - port: 80
    targetPort: 80
    protocol: TCP
    name: http

---

#removed annotation, as here we are using GKE Ingress
apiVersion: extensions/v1beta1
kind: Ingress
metadata: 
  name: mycha-ingress
spec:
  rules:
    - http:
        paths:
        - path: /
          backend:
            serviceName: mycha-svc
            servicePort: 80


deployment.apps/mycha-deploy created
service/mycha-svc created
ingress.extensions/mycha-ingress created
</code></pre>
<p>You should be able to see output like below:</p>
<pre><code>$ kubectl get pods,svc,ing
NAME                                READY   STATUS    RESTARTS   AGE
pod/mycha-deploy-685f894996-xbbnv   1/1     Running   0          38s

NAME                 TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)        AGE
service/kubernetes   ClusterIP   10.99.0.1     &lt;none&gt;        443/TCP        33d
service/mycha-svc    NodePort    10.99.13.51   &lt;none&gt;        80:30808/TCP   39s

NAME                               HOSTS   ADDRESS        PORTS   AGE
ingress.extensions/mycha-ingress   *       34.107.251.59  80      3m3s
</code></pre>
<p>Now you should be able to curl your svc.</p>
<pre><code>$ curl 34.107.251.59
...
&lt;body&gt;
&lt;h1&gt;Welcome to nginx!&lt;/h1&gt;
&lt;p&gt;If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.&lt;/p&gt;
</code></pre>
<p>As you are using GKE Ingress, your <code>Ingress</code> will automatically received EXTERNAL-IP. If you will keep <code>service</code> as <code>ClusterIP</code> it won't receive any <code>Address</code>.</p>
<pre><code>$ kubectl get ing
NAME            HOSTS   ADDRESS   PORTS   AGE
mycha-ingress   *                 80      34m
</code></pre>
<blockquote>
<p>In the Service manifest, notice that the type is NodePort. This is the required type for an Ingress that is used to configure an HTTP(S) load balancer.
More detailed information can be found <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/ingress" rel="nofollow noreferrer">here</a>.</p>
</blockquote>
<p><strong>2. Nginx Ingress on GKE</strong></p>
<p>When you are using <code>Nginx Ingress</code> you can specify your service as <code>ClusterIP</code> or <code>NodePort</code>.</p>
<p>To do that you need to deploy proper <code>Nginx Ingress</code>.
Good tutorail can be found <a href="https://cloud.google.com/community/tutorials/nginx-ingress-gke" rel="nofollow noreferrer">here</a>, however it's bit outdated. I am posting below updated steps:</p>
<ul>
<li>Install <a href="https://helm.sh/docs/intro/install/#from-script" rel="nofollow noreferrer">Helm v3</a>. This version don't require <code>tiller</code>.</li>
<li>Add proper repository for <code>Helm 3</code>. Details can be found <a href="https://github.com/helm/charts#how-do-i-enable-the-stable-repository-for-helm-3" rel="nofollow noreferrer">here</a>.</li>
</ul>
<p>Adding and updating repo:</p>
<pre><code>$ helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
$ helm repo update
</code></pre>
<ul>
<li>Apply your deploymnet and service (<code>NodePort</code> or <code>ClusterIP</code>, using <code>Nginx Ingress</code> both types will work).</li>
<li>Deploy <code>Nginx Ingress</code> using  <code>$ helm install ingress-nginx ingress-nginx/ingress-nginx</code>. It will create 2 <code>deployments</code> and 2 <code>services</code>. One of services will be created as <code>LoadBalancer</code>.</li>
<li>Deploy Ingress</li>
</ul>
<p>With <code>annotation.kubernetes.io/ingress.class: &quot;nginx&quot;</code></p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata: 
  name: mycha-ingress
  annotations:
    kubernetes.io/ingress.class: &quot;nginx&quot;
spec:
  rules:
  - http:
      paths:
        - path: /
          backend:
            serviceName: mycha-svc
            servicePort: 80
</code></pre>
<p>You should have output like:</p>
<pre><code>$ kk get pods,svc,ing
NAME                                                READY   STATUS    RESTARTS   AGE
pod/mycha-deploy-c469dc58b-mdp6d                    1/1     Running   0          2m41s
pod/nginx-ingress-controller-5d47f75dfc-d6xnl       1/1     Running   0          7m18s
pod/nginx-ingress-default-backend-f5b888f7d-rf5cx   1/1     Running   0          7m18s

NAME                                    TYPE           CLUSTER-IP     EXTERNAL-IP     PORT(S)                      AGE
service/kubernetes                      ClusterIP      10.99.0.1      &lt;none&gt;          443/TCP                      33d
service/mycha-svc                       ClusterIP      10.99.8.140    &lt;none&gt;          80/TCP                       2m12s
service/nginx-ingress-controller        LoadBalancer   10.99.11.177   34.90.172.116   80:31593/TCP,443:30104/TCP   7m19s
service/nginx-ingress-default-backend   ClusterIP      10.99.7.106    &lt;none&gt;          80/TCP                       7m19s

NAME                               HOSTS   ADDRESS   PORTS   AGE
ingress.extensions/mycha-ingress   *                 80      17s
</code></pre>
<p>Your <code>Ingress</code> will not receive any <code>Address</code> as <code>service/nginx-ingress-controller</code> will work as LoadBalancer.</p>
<p>Now you can check if everything works using curl.</p>
<pre><code>$ curl 34.90.172.116
&lt;!DOCTYPE html&gt;
...
&lt;h1&gt;Welcome to nginx!&lt;/h1&gt;
&lt;p&gt;If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.&lt;/p&gt;
</code></pre>
