Zama Ques
Zama Ques

Reputation: 1534

404 not found for GKE Ingress

I am trying with Ingress feature in GKE Cluster` . Following are the steps I followed

  1. Create deployment with below command

     kubectl create deployment hello --image=gcr.io/google-samples/hello-app:2.0

  2. Exposed the deployment of type NodePort

     kubectl expose deployment hello --port=8080 --type=NodePort

  3. my ingress manifests is as follows

 apiVersion: networking.k8s.io/v1beta1
 kind: Ingress
 metadata:
   name: basic-ingress
   annotations:
      kubernetes.io/ingress.class: gce 
 spec:
   rules:      
   - http:
       paths:
       - path: /
       backend:
         serviceName: hello
         servicePort: 8080              

$ kubectl get services
  NAME         TYPE           CLUSTER-IP    EXTERNAL-IP     PORT(S)            AGE
  hello       NodePort        10.0.41.132     <None>      8080:30820/TCP       113m

$ kubectl get ingress
  NAME            HOSTS      ADDRESS        PORTS    AGE
  basic-ingress    *       35.X.X.X        80      26m

But when I access the external IP using curl , it throws 404 not found .

Below error can be seen from GKE Console

enter image description here I think I am missing something in the ingress definition . Please guide to fix this.

Image definition has been taken from this guide https://cloud.google.com/kubernetes-engine/docs/tutorials/http-balancer

Upvotes: 0

Views: 2129

Answers (2)

Zama Ques
Zama Ques

Reputation: 1534

The same YAML definitions are failing for me in a SharedVPC . This got resolved after adding the below firewall rule

  gcloud compute firewall-rules create k8s-fw-l7--60cada75751e6d79 --network <SharedVPC> --description "GCE L7 firewall rule" --allow tcp:30000-32767 --source-ranges 130.211.0.0/22,209.85.152.0/22,209.85.204.0/22,35.191.0.0/16 --target-tags gke-privatetestgkecluster-cf899a18-node --project <Project> 

https://cloud.google.com/load-balancing/docs/health-checks

Upvotes: 0

blueboy1115
blueboy1115

Reputation: 161

I have tried to create the same ingress from the scratch (none cluster, none ingress service, none service), and I was able to create it and perform a curl successfully, these were the steps:

1.- Create a cluster (It does not matter the details, just create it as you want)

2.- Connect to the cluster and install kubectl-> sudo apt-get install kubectl

3.- kubectl create deployment hello --image=gcr.io/google-samples/hello-app:2.0

4.- kubectl expose deployment hello --port=8080 --type=NodePort

5.- Create the ingress as follows (Without annotations), as per Creating an Ingress resource

apiVersion: networking.k8s.io/v1beta1 kind: Ingress metadata: name: basic-ingress spec: backend: serviceName: web servicePort: 8080

6.- Review your ingress kubectl get ingress basic-ingress

@cloudshell:$ kubectl get ingress basic-ingress NAME HOSTS ADDRESS PORTS AGE basic-ingress * 130.211.xx.xxx 80 5m46s

7.- And now is working when I have performed the curl:

@cloudshell:$ curl http://130.211.xx.xxx Hello, world! Version: 2.0.0 Hostname: hello-86dbf5b7c6-f7qgl

You were using ingress annotations, and it is another way to create ingress services, but a little bit more advanced. My suggestion is to create it as simple as possible first.

Please try it at this way and let me know about it.

Upvotes: 1

Related Questions