Home > database >  Application not accessible using ingress but works with LoadBalancer GKE
Application not accessible using ingress but works with LoadBalancer GKE

Time:09-13

I am trying to configure a hello world application using ingress in GKE. I have been referring a GCP official documentation to deploy an application using Ingress.

Deploying an app using ingress

But this does not work i have tried to refer several documents but none of those work. I have installed the ingress controller in my kubernetes cluster.

kubectl get svc -n ingress-nginx returns below output

NAME                                 TYPE           CLUSTER-IP       EXTERNAL-IP      PORT(S)     
AGE
ingress-nginx-controller             LoadBalancer   10.125.177.232   35.232.139.102   80:31835/TCP,443:31583/TCP   7h24m

kubectl get pods-n ingress-nginx returns

NAME                                        READY   STATUS      RESTARTS   AGE
ingress-nginx-admission-create-jj72r        0/1     Completed   0          7h24m
ingress-nginx-admission-patch-pktz6         0/1     Completed   0          7h24m
ingress-nginx-controller-5cb8d9c6dd-vptkh   1/1     Running     0          7h24m

kubectl get ingress returns below output

NAME               CLASS    HOSTS                   ADDRESS       PORTS   AGE
ingress-resource   <none>   35.232.139.102.nip.io   34.69.2.173   80      7h48m

kubectl get pods returns below output

NAME                         READY   STATUS    RESTARTS   AGE
hello-app-6d7bb985fd-x5qpn   1/1     Running   0          43m

kubect get svc returns below output

NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)             AGE
hello-app    ClusterIP   10.125.187.239   <none>        8080/TCP            43m

Ingress resource yml file used

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-resource
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
  rules:
  - host: 35.232.139.102.nip.io
    http:
      paths:
      - pathType: Prefix
        path: "/hello"
        backend:
          service:
            name: hello-app
            port:
              number: 8080

Can someone tell me what i am doing wrong ? When i try to reach the application its not working.

CodePudding user response:

So I have installed Ingress-controller and used ingress controller ip as the host in my ingress file.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-resource
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
  rules:
  - host: "35.232.139.102.nip.io"
    http:
      paths:
      - pathType: Prefix
        path: "/hello"
        backend:
          service:
            name: hello-app
            port:
              number: 8080

Issue here was I forgot to add the IP from which I was accessing the application. When you create a GKE cluster there will be a firewall with the cluster-name-all in this firewall you will need to add your IP address of the machine from which you are trying to access the application. Also ensure that the port number is also exposed in my case both were not provided hence it was failing.

  • Related