skip to Main Content

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


  1. Chosen as BEST ANSWER

    According to my test result,

    I can't export a hostNetwork service by ingress.

    Here is my result matrix:

    headless clusterIP
    hostNetwork: True 502 502
    hostNetwork: False

  2. Basically, headless Services are of the same type as default ClusterIP, which exposes Service on a cluster-internal IP – the only difference is that headless 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 :

    • ClusterIP: Exposes the Service on a cluster-internal IP. Choosing this value makes the Service only reachable from within the cluster. This is the default ServiceType.

    As per hostNetwork, when it is set to True, 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search