I created ingress resource but it is not working. Please note - I have not deployed the ingress controller using gke default ( is this mandatory to deploy ingress controller in managed gke )
I have created two nginx deployment and nodeport service respectively
NAME READY STATUS RESTARTS AGE
pod/app1-57df48bcd9-d48l9 1/1 Running 0 69m
pod/app2-8478484c64-khn5w 1/1 Running 0 69m
pod/test-d4df74fc9-kkzjd 1/1 Running 0 42m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/app1 NodePort 10.121.13.120 <none> 8080:32252/TCP 67m
service/app2 NodePort 10.121.15.112 <none> 80:31412/TCP 58m
service/kubernetes ClusterIP 10.121.0.1 <none> 443/TCP 79m
service/test NodePort 10.121.13.108 <none> 6060:32493/TCP 42m
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/app1 1/1 1 1 69m
deployment.apps/app2 1/1 1 1 69m
deployment.apps/test 1/1 1 1 42m
NAME DESIRED CURRENT READY AGE
replicaset.apps/app1-57df48bcd9 1 1 1 69m
replicaset.apps/app2-8478484c64 1 1 1 69m
replicaset.apps/test-d4df74fc9 1 1 1 42m
=========================
and deployed ingress resource as per below
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: connection
spec:
rules:
- http:
paths:
- path: /app1
backend:
serviceName: app1
servicePort: 8080
- path: /app2
backend:
serviceName: app2
servicePort: 80
Ingress description
Name: connection
Namespace: default
Address: xxxxxxxxxxxxx
Default backend: default-http-backend:80 (10.56.0.9:8080)
Rules:
Host Path Backends
---- ---- --------
*
/ app1:8080 (10.56.2.4:80)
/app2 app2:80 (10.56.1.4:80)
Annotations: ingress.kubernetes.io/backends:
{"k8s-be-31412--b52155807170af3c":"HEALTHY","k8s-be-32252--b52155807170af3c":"HEALTHY","k8s-be-32504--b52155807170af3c":"HEALTHY"}
ingress.kubernetes.io/forwarding-rule: k8s-fw-default-connection--b52155807170af3c
ingress.kubernetes.io/rewrite-target: /
ingress.kubernetes.io/target-proxy: k8s-tp-default-connection--b52155807170af3c
ingress.kubernetes.io/url-map: k8s-um-default-connection--b52155807170af3c
ingress.kubernetes.io/use-regex: true
kubernetes.io/ingress.class: gce
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ADD 58m loadbalancer-controller default/connection
Normal CREATE 57m loadbalancer-controller ip: xxxxxxxxxx
when I am trying to access http://ingresLBip/app1
or http://ingessLBip/app2
I am getting 404 not found error
if I configure ingres resouce with single backend then it is working for single service.
Is anyone face this issue on gke? do i need to install nginx controller as well?
I am assuming your applications are listening to /
and not /app1
or /app2
paths. That would explain why the single backend is working. There seems to be a limitation in gce-ingress
controller that it doesn't support rewrite-target
annotation. If that thread is current then either you have to update the applications to work with the paths or you will have to ditch gce-ingress
and use nginx-ingress
.
You could use nginx ingress because support for rewrite-target annotation in GKE ingress is not there yet.
Install nginx ingress following the docs. Change the ingress resource as below
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: connection
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
kubernetes.io/ingress.class: nginx
spec:
rules:
- http:
paths:
- path: /app1
backend:
serviceName: app1
servicePort: 8080
- path: /app2
backend:
serviceName: app2
servicePort: 80