I have deployed an app with Google Kubernetes Engine. All function works perfectly but I have a strange problem. If I check the status in Google cloud console the ingress is always in creating phase.
You can see it in image:
Have you some suggestion to resolve it?
Thanks
[EDIT]
kubectl describe ingress:
Name: ++++++-nginx-ingress
Namespace: ++++++
Address:
Default backend: default-http-backend:80 (10.4.0.4:8080)
Rules:
Host Path Backends
---- ---- --------
++++++-back.*******.net
++++++-nginx-np:80 (<none>)
++++++.*******.net
++++++-front-np:80 (<none>)
Annotations:
ingress.kubernetes.io/backends: {"k8s-be-30141--93abcf3e6a0e0671":"HEALTHY","k8s-be-32338--93abcf3e6a0e0671":"HEALTHY","k8s-be-32589--93abcf3e6a0e0671":"HEALTHY"}
ingress.kubernetes.io/url-map: k8s-um-++++++-++++++-nginx-ingress--93abcf3e6a0e0671
kubectl.kubernetes.io/last-applied-configuration: {"apiVersion":"extensions/v1beta1","kind":"Ingress","metadata":{"annotations":{"kubernetes.io/ingress.allow-http":"false","kubernetes.io/ingress.global-static-ip-name":"++++++-nginx-ingress-ip"},"labels":{"app":"++++++-nginx-ingress"},"name":"++++++-nginx-ingress","namespace":"++++++"},"spec":{"rules":[{"host":"++++++-back.*******.net","http":{"paths":[{"backend":{"serviceName":"++++++-nginx-np","servicePort":80}}]}},{"host":"++++++.*******.net","http":{"paths":[{"backend":{"serviceName":"++++++-front-np","servicePort":80}}]}}]}}
kubernetes.io/ingress.allow-http: false
kubernetes.io/ingress.global-static-ip-name: ++++++-nginx-ingress-ip
Events:
<none>
YAML file:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ++++++-nginx-ingress
labels:
app: ++++++-nginx-ingress
annotations:
kubernetes.io/ingress.global-static-ip-name: ++++++-nginx-ingress-ip
kubernetes.io/ingress.allow-http: "false"
namespace: ++++++
spec:
rules:
- host: ++++++-back.++++++.net
http:
paths:
- backend:
serviceName: ++++++-nginx-np
servicePort: 80
- host: ++++++.++++++.net
http:
paths:
- backend:
serviceName: ++++++-front-np
servicePort: 80
Checking your output I can see that the loadbalncer is not created or not getting your static IP ++++++-nginx-ingress-ip normally after the Spec.Backend
status:
loadBalancer:
ingress:
- ip: xx.xx.xx.xx
On thing the Annotation kubernetes.io/ingress.allow-http: "false" is used when TLS for the ingress is configured.
Another thing you may check if the Add-on for L7 HTTP load balancing is Enabled by default when creating the cluster is enabled
Related
I have the following ingress...
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: core-ingress
namespace: earth
annotations:
kubernetes.io/ingress.global-static-ip-name: "core-proxy-static-ip"
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: core-ingress
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: core-proxy-service
port:
number: 80
I have used kubectl exec to make sure the service itself is running and listening on port 80 so I know core-proxy-service is working. When I try to install the ingress it never gets and IP and the events show nothings...
Name: core-ingress
Namespace: earth
Address:
Default backend: default-http-backend:80 (10.109.128.78:8080)
Rules:
Host Path Backends
---- ---- --------
*
/ core-proxy-service:80 (10.109.128.132:80)
Annotations: kubernetes.io/ingress.global-static-ip-name: core-proxy-static-ip
nginx.ingress.kubernetes.io/rewrite-target: /
Events: <none>
Since there are no events I figure something must have happened and that is why I am not getting an IP but how would I be able to debug to figure out what?
NAMESPACE NAME CLASS HOSTS ADDRESS PORTS AGE
earth core-ingress core-ingress * 80 3m33s
Update
If I revert back to
defaultBackend:
service:
name: core-proxy-service
port:
number: 80
Everything works what am I missing?
Try something like :
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-myservicea
annotations:
kubernetes.io/ingress.global-static-ip-name: "core-proxy-static-ip"
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /
backend:
serviceName: core-proxy-service
servicePort: 80
Ref doc : https://kubernetes.github.io/ingress-nginx/user-guide/basic-usage/
I have the following ingress:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-ingress
namespace: apps
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/custom-http-errors: '404'
spec:
tls:
- hosts:
- mywebsite.com
secretName: my-secret-tls
rules:
- host: mywebsite.com
- http:
paths:
- path: /api/events
pathType: ImplementationSpecific
backend:
service:
name: my-events-api-svc
port:
number: 80
When I kubectl describe this ingress, I see the following
Name: my-ingress
Namespace: apps
Address: 52.206.112.10
Default backend: default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
TLS:
my-secret-tls terminates mywebsite.com
Rules:
Host Path Backends
---- ---- --------
*
/api/events my-events-api-svc:80 (10.244.4.145:4000,10.244.5.118:4000)
Annotations: kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/custom-http-errors: 404
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal UPDATE 9s (x7 over 153m) nginx-ingress-controller Ingress apps/my-ingress
The issue is that the specified path doesn't work, I'm getting 404. I noticed that in the output above, there is a * under the Host. My other ingresses are configured pretty much the same (only have different paths set), and there is no * in the kubectl describe output. Instead, in my other ingresses the proper Host - "mywebsite.com" - is shown.
The output above also has some error (<error: endpoints "default-http-backend" not found>), but I see it as well in my other ingresses (that do work).
What could be the problem?
Its your indentation, please check official example
spec:
rules:
- host: hello-world.info
http:
paths:
Try
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-ingress
namespace: apps
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/custom-http-errors: '404'
spec:
tls:
- hosts:
- mywebsite.com
secretName: my-secret-tls
rules:
- host: mywebsite.com
http:
paths:
- path: /api/events
pathType: ImplementationSpecific
backend:
service:
name: my-events-api-svc
port:
number: 80
I have a web app and its corresponding backend service deployed in k8s. They are exposed as follows through services:
Web App -> http://1.2.3.4:8080/webapp/login
Backend -> http://5.6.7.8:8081/backend-service/login
I have configured ingress resource for these service but it turns out NGINX ingress controller is skipping the context root part while rewriting the url which is making my service unavailable when I am deploying it through ingress. Below is my ingress resource:
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
namespace: default
name: gateway-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1
nginx.ingress.kubernetes.io/use-regex: true
spec:
rules:
- http:
paths:
- path: /webapp/*
backend:
serviceName: webapp-service
servicePort: 8080
- path: /backend-service/*
backend:
serviceName: backend-service
servicePort: 8081
**Output of : kubectl describe ingress gateway-ingress**
Name: gateway-ingress
Namespace: default
Address: test.elb.us-east-2.amazonaws.com
Default backend: default-http-backend:80 (<none>)
Rules:
Host Path Backends
---- ---- --------
*
/webapp/* webapp-service:8080 (1.2.3.4:8080)
/backend-service/* backend-service:8081 (5.6.7.8:8081)
So when I am accessing my application using http://test.elb.us-east-2.amazonaws.com/webapp/login I am getting 404 not found. How can i configure ingress resource correctly?
Application context removal is caused by the rewrite-target annotation. Just remove it if it's not needed.
The ingress I config to run with the controller ingress-nginx.
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: app-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
tls:
- hosts:
- XXX.XX.com
secretName: app-tls
rules:
- host: XXX.XX.com
http:
paths:
- path: /my-api(/|$)(.*)
backend:
serviceName: app
servicePort: 80
---
apiVersion: v1
kind: Service
metadata:
name: my-api
spec:
selector:
app: my-api
ports:
- name: app
port: 3000
targetPort: 3000
I can run the api locally curl localIP:3000/testapi, but it can not run remotely.
# kubectl describe ingress app-ingress
Name: app-ingress
Namespace: default
Address: XX.XX.XX.XX
Default backend: default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
TLS:
app-tls terminates www.daichenchen.cn
Rules:
Host Path Backends
---- ---- --------
XXX.XX.com
/my-api(/|$)(.*) app:80 (<error: endpoints "app" not found>)
I already succeed install the ingress-nginx and all the pod work without error.
Your defined serviceName in Ingress rules and Service should be same.
Like this :
...
rules:
- host: XXX.XX.com
http:
paths:
- path: /my-api(/|$)(.*)
backend:
serviceName: app
servicePort: 80
apiVersion: v1
kind: Service
metadata:
name: app
spec:
selector:
app: my-api
ports:
- name: app
port: 3000
targetPort: 3000
If Ingress and the Service is in different namespace, you can also add the service name to the ingress rule. In this case you need to use dns name for service <service-name>.<namespace>.
For example:
rules:
- host: example.com
http:
paths:
- path: /my-api
backend:
serviceName: test-service.test-namespace
servicePort: 80
apiVersion: v1
kind: Service
metadata:
name: test-service
namespace: test-namespace
The way ingress controller finds out Endpoints of a service is it searches for a kubernetes service with the serviceName provided in the ingress resource in the namespace where you have created the ingress resource. If there is no kubernetes service with serviceName found you get endpoints not found.
The Endpoints of the service contains the IPs of pods behind the kubernetes service.
So in your case either the kubernetes service does not exist or it's in a different namespace than where ingress resource is created.
Some variant of nginx ingress controller does not support default backend and for this it's expected to have the error: endpoints "default-http-backend" not found
Another variant of nginx ingress controller supports default backend.
Double check which variant of nginx ingress controller you installed
All,
I followed this tutorial: https://github.com/ahmetb/gke-letsencrypt.
I have an ingress setup for kubernetes in Google Cloud, I have a static IP address and the secrets are created.
This is my ingress config:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: helloweb
annotations:
kubernetes.io/ingress.global-static-ip-name: helloweb-ip
certmanager.k8s.io/acme-http01-edit-in-place: "true"
labels:
app: hello
spec:
backend:
serviceName: helloweb-backend
servicePort: 8080
tls:
- secretName: dogs-com-tls
hosts:
- app-solidair-vlaanderen.com
I can access http://app-solidair-vlaanderen.com, but not the https url.
If I call describe ingress I get this output:
Name: helloweb
Namespace: default
Address: 35.190.68.173
Default backend: helloweb-backend:8080 (10.32.0.17:8080)
TLS:
dogs-com-tls terminates app-solidair-vlaanderen.com
Rules:
Host Path Backends
---- ---- --------
app-solidair-vlaanderen.com
/.well-known/acme-challenge/Q8kcFSZ0ZUJO58xZyVbK6s-cJIWu-EgwPcDd8NFyoXQ cm-acme-http-solver-mhqnf:8089 (<none>)
Annotations:
url-map: k8s-um-default-helloweb--17a833239f9491d9
backends: {"k8s-be-30819--17a833239f9491d9":"Unknown","k8s-be-32482--17a833239f9491d9":"HEALTHY"}
forwarding-rule: k8s-fw-default-helloweb--17a833239f9491d9
target-proxy: k8s-tp-default-helloweb--17a833239f9491d9
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ADD 45m loadbalancer-controller default/helloweb
Normal CREATE 44m loadbalancer-controller ip: 35.190.68.173
Warning Sync 7m (x22 over 28m) loadbalancer-controller Error during sync: error while evaluating the ingress spec: could not find service "default/cm-acme-http-solver-mhqnf"
Does someone know what I'm missing?
You have some mess up in your ingress definition, why the hosts is under the tls?
Here is an example that is working for me:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ .Values.ingressName }}-ingress
annotations:
kubernetes.io/ingress.global-static-ip-name: {{ .Values.staticIpName }}-static-ip
kubernetes.io/ingress.allow-http: "false"
labels:
...
spec:
tls:
- secretName: sslcerts
rules:
- host: {{ .Values.restApiHost }}
http:
paths:
- backend:
serviceName: rest-api-internal-service
servicePort: 80