Does nginx ingress controller able to export a headless service?
The underlaying pod is using hostNetwork
.
Is there documentation for this?
Specifically, I’m trying to export node-export service(manifest comes from kube-prometheus
) by nginx ingress controller.
a short code of ingress:
...
- path: /node-exporter
pathType: Prefix
backend:
serviceName: node-exporter
servicePort: 9100
...
a short code of service:
...
spec:
clusterIP: None
ports:
- name: https
port: 9100
targetPort: https
selector:
app.kubernetes.io/name: node-exporter
...
2
Answers
According to my test result,
I can't export a hostNetwork service by ingress.
Here is my result matrix:
Basically,
headless Services
are of the same type as defaultClusterIP
, which exposes Service on a cluster-internal IP – the only difference is thatheadless service
allows clients to connect to pod directly without proxy.I was referring to this part in Kubernetes doc, where it is stated that
ClusterIP
is supposed to be accessible only from within the cluster, while ingress would expose it outside of the cluster :As per
hostNetwork
, when it is set toTrue
, a pod is granted access to the services listening on localhost, it can use the node network namespace and therefore see and use network interfaces of the host machine. In its turn, the pod would be accessible on these network interfaces and it can receive outside traffic directly.