I have this yaml for an Ingress:
kind: Ingress
apiVersion: extensions/v1beta1
metadata:
name: app
namespace: ingress-controller
... omitted for brevity ...
spec:
rules:
- host: ifs-alpha-kube-001.example.com
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: service-nodeport
servicePort: 80
- path: /
pathType: ImplementationSpecific
backend:
serviceName: service-nodeport
servicePort: 443
status:
loadBalancer:
ingress:
- {}
In the above I set ...
- host: ifs-alpha-kube-001.example.com
That host just happens to be one of my nodes. I have three nodes. I am pretty certain that this incorrect. The ingress works but if I shutdown ifs-alpha-kube-001 the ingress stops working. What should I set host
if I want a high availability cluster?
Thanks
Update: I tried out duct_tape_coder's suggestion but I still must be doing something wrong.
I need to be able to access web servers on both port 80 and 443 so I create two "single service" ingresses.
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: port-80-ingress
namespace: ingress-controller
spec:
backend:
serviceName: port-80-service
servicePort: 80
... and ...
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: port-443-ingress
namespace: ingress-controller
spec:
backend:
serviceName: port-443-service
servicePort: 443
And I deleted my old ingress. But I still only able to access the web server on my first node, ifs-alpha-kube-001, and not ifs-alpha-kube-002 and ifs-alpha-kube-003. I verified that my web server is running on the pods.
Update II:
Ok I tried this instead:
kind: Ingress
apiVersion: extensions/v1beta1
metadata:
name: app2
namespace: ingress-controller
... omitted ...
spec:
rules:
- http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: service-nodeport
servicePort: 80
- path: /
pathType: ImplementationSpecific
backend:
serviceName: service-nodeport
servicePort: 443
status:
loadBalancer:
ingress:
- {}
$ kubectl describe ingress app2 --namespace=ingress-controller
Name: app2
Namespace: ingress-controller
Address:
Default backend: default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
Host Path Backends
---- ---- --------
*
/ service-nodeport:80 (10.233.119.22:80,10.233.123.33:80,10.233.125.29:80)
/ service-nodeport:443 (10.233.119.22:443,10.233.123.33:443,10.233.125.29:443)
Annotations: Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal CREATE 13m ingress-controller Ingress ingress-controller/app2
Normal CREATE 13m ingress-controller Ingress ingress-controller/app2
Normal UPDATE 12m ingress-controller Ingress ingress-controller/app2
Normal UPDATE 12m ingress-controller Ingress ingress-controller/app2
And deleted all other ingresses. But still I can only access http on host ifs-alpha-kube-001 with the weird twist ... if I execute:
curl -L --insecure https://ifs-alpha-kube-001.example.com -vvvv
I get a ton of output about redirection.
> GET / HTTP/2
> Host: ifs-alpha-kube-001
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/2 302
< date: Tue, 23 Jun 2020 15:52:28 GMT
< server: Apache/2.4.39 (Unix) OpenSSL/1.0.2k-fips mod_wsgi/4.7.1 Python/3.6
< location: https://ifs-alpha-kube-001/
< content-length: 211
< content-type: text/html; charset=iso-8859-1
< strict-transport-security: max-age=15768000
<
* Ignoring the response-body
* Connection #1 to host ifs-alpha-kube-001 left intact
* Maximum (50) redirects followed
curl: (47) Maximum (50) redirects followed
* Closing connection 0
* Closing connection 1
What is going on here?
Update III
Here are the services I have set up:
$ kubectl get service --namespace=ingress-controller -o wide
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
haproxy-ingress NodePort 10.233.23.21 <none> 80:30032/TCP,443:30643/TCP,1936:30302/TCP 6d4h run=haproxy-ingress
ingress-default-backend ClusterIP 10.233.5.224 <none> 8080/TCP 6d5h run=ingress-default-backend
service-nodeport NodePort 10.233.3.139 <none> 80:30080/TCP,443:30443/TCP 5d18h k8s-app=test-caasa-httpd,pod-template-hash=7d79794567
I believe I have tied the service-nodeport
service to my ingress app2
.
Don't set a host and it'll be available on all hosts, https://kubernetes.io/docs/concepts/services-networking/ingress/. You can also designate a hostPort for it to be available on a specific port on all hosts. I would recommend doing that, then using an external load balancer/proxy to hit the ingress hostport on all nodes.