0
votes

I am trying to deploy my application using GKE: I added an ingress ressource using this link https://kubernetes.io/docs/concepts/services-networking/ingress/

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress
  annotations:
    kubernetes.io/ingress.global-static-ip-name: app-ip
  labels:
    app: myapp
    part: ingress
spec:
 rules:
  - http:
      paths:
      - path: /*
        backend:
          serviceName: frontapp
          servicePort: 3000
      - path: /back/*
        backend:
          serviceName: backapp
          servicePort: 9000

and exposed my services as NodePort : Only the service mapped to "/" works ( I tested with the both front and back services)

(paths mapped to this do not work

[IP]/back/(my paths)

In the tutorial I found this sentence:

You need an Ingress controller to satisfy an Ingress, simply creating the resource will have no effect.

My question is:

1) what is the difference between the ingress ressource and controller?

2)Does GKE offer an ingress controller by default or should I add it manually in order to fix my path issue ?

3)What else could be wrong with my configuration

Ps: this one of my services

apiVersion: v1
 kind: Service
 metadata:
   labels:
     app: myapp
     part: back
   name: backapp
   namespace: default
 spec:
   ports:
   - port: 9000
     protocol: TCP
     targetPort: 9000 # Port on the pod with 'back' application
   selector:
     app: myapp
     part: back
   type: NodePort

and this what I get when I describe my ingress

Annotations:
  ingress.kubernetes.io/url-map:                k8s-um-default-ingress--17c7235ab3ece101
  kubernetes.io/ingress.global-static-ip-name:  app-ip
  ingress.kubernetes.io/backends:               {"k8s-be-31278--17c7235ab3ece101":"HEALTHY","k8s-be-32112--17c7235ab3ece101":"HEALTHY","k8s-be-32287--17c7235ab3ece101":"HEALTHY"}
  ingress.kubernetes.io/forwarding-rule:        k8s-fw-default-ingress--17c7235ab3ece101
  ingress.kubernetes.io/target-proxy:           k8s-tp-default-ingress--17c7235ab3ece101


Events:   Type    Reason   Age               From                     Message   ----    ------   ----              ----                    
-------

 Warning  UrlMap   46m (x5 over 4h)  loadbalancer-controller  googleapi: Error 412: Invalid fingerprint., conditionNotMet

  Normal  Service  4m (x22 over 2h)  loadbalancer-controller  no user specified default backend, using system default
1
Seems u have a extra sign after the port number: servicePort: 9000 ` (is this a typo?)Tim
it is an error when writing the question ( I do not have it in my code )Ennar.ch
Notice that your paths overlap (/* also matches /back/*). I don't know if this is the issue, but what happens when you change the order of these paths in your ingress definition? If you create an ingress resource, GKE creates a HTTP(S) Load Balancer with an URL map that corresponds to your ingress spec. cloud.google.com/load-balancing/docs/https/url-mapPiotr Kuciapski
thank you, I did already change the order , nothing changedEnnar.ch
remove trailing slashes and asterisks from the path .... /back/foo/bar will match /back.AWippler

1 Answers

0
votes

1) Ingress is a Kubernetes resource that encapsulates a collection of rules and configuration for routing external HTTP(S) traffic to internal services. An ingress controller is responsible for reading the Ingress Resource information and processing that data accordingly, You need an Ingress controller to satisfy an Ingress, simply creating the resource will have no effect.

2) By default yes its GLBC ,you can deploy an app without using an ingress resources. GKE uses GLBC by default the GLBC ingress controller and you don't have to configue the path, as the path is configured in your ingress resource (your YAML file).

Ingress is tightly integrated into Kubernetes, meaning that your existing workflows around kubectl will likely extend nicely to managing ingress. Note that an ingress controller typically doesn’t eliminate the need for an external load balancer — the ingress controller simply adds an additional layer of routing and control behind the load balancer.

3)According to your Ingress resource yaml : - routes the requests with path starting with /Back/ to the backapp Service. - routes all other requests to the frontapp Service.

Upon checking the Yaml configuration and the UrlMap you are getting, I suggest you to add the Host under your rules, since a IngressRule without a host gets the wildcard.