I would like to use multiple rules under the one ingress name.
{
"kind": "Ingress",
"spec": {
"rules": [
{
"host": "gke-service-xyz.com",
"http": {
"paths": [
{
"path": "/",
"backend": {
"serviceName": "gke-service",
"servicePort": 8080
}
}
]
}
},
{
"host": "gke-service1-xyz.com",
"http": {
"paths": [
{
"path": "/",
"backend": {
"serviceName": "gke-service1",
"servicePort": 8081
}
}
]
}
}
]
},
"apiVersion": "extensions/v1beta1",
"metadata": {
"annotations": {
"kubernetes.io/ingress.class": "nginx",
"nginx.ingress.kubernetes.io/ssl-redirect": "false"
},
"name": "javaservice1-ingress"
},
"namespace": "abc-namespace"
}
YAML CODE
kind: Ingress
spec:
rules:
- host: gke-service-xyz.com
http:
paths:
- path: "/"
backend:
serviceName: gke-service
servicePort: 8080
- host: gke-service1-xyz.com
http:
paths:
- path: "/"
backend:
serviceName: gke-service1
servicePort: 8081
apiVersion: extensions/v1beta1
metadata:
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/ssl-redirect: 'false'
name: javaservice1-ingress
namespace: abc-namespace
Here the problem is the first ingress host is working fine but while fetching the second ingress host is not working and it is showing like, 503 Service Temporarily Unavailable. I want both the hosts in a working state. Is there any way to achieve the same?
Above points 1 and 2 are the ingress endpoints both should work but here only 1 is in working. Both the above YAML codes are not working.
Try this -
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1
kubernetes.io/ingress.class: nginx
name: staging-ingress
spec:
rules:
- host: gke-service-xyz.com
http:
paths:
- path: /(.*)
backend:
serviceName: gke-service
servicePort: 8080
- path: /api/(.*)
backend:
serviceName: gke-service1
servicePort: 8081
The question you are asking is something like that you want to have only one domain and use it to route to two services, hence you can use something like URL rewrite for this