<p>I have a very simple program:</p>
<pre><code>package main

import (
    &quot;fmt&quot;
    &quot;github.com/vishvananda/netlink&quot;
    )

func main() {
    _, err := netlink.LinkByName(&quot;wlp164s0&quot;)
    if err != nil {
        fmt.Println(&quot;error finding VIP Interface, for building DHCP Link : %v&quot;, err)
        return
    }
    fmt.Println(&quot;Worked..&quot;)
}
</code></pre>
<p>If I create a docker image and run it with &quot;--net host&quot;, this program prints &quot;Worked&quot;. It is able to find the interface wlp164s0.</p>
<p>If I create a k8s deployment like this:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: netlink-example
  labels:
    app: netlink-example
spec:
  replicas: 1
  selector:
    matchLabels:
      app: netlink-example
  template:
    metadata:
      labels:
        app: netlink-example
    spec:
      hostNetwork: true
      containers:
      - name: netlink
        image: suruti94/netlink:0.1
        imagePullPolicy: IfNotPresent
      hostNetwork: true
      nodeSelector:
        kubernetes.io/os: linux
</code></pre>
<p>This program prints the error indicating that it can't lookup the interface which means the &quot;hostNetwork: true&quot; is not taking effect. From all my research, this looks right. Any help would be appreciated. I am running this program on Ubuntu 21.04, k8s version 1.22.</p>

<p>After some experimentation, I have come to an understanding that the docker option &quot;--net host&quot; is not the same as &quot;hostNetwork: true&quot; in k8s. I wrongly assumed they produce similar behavior.</p>
<ul>
<li>docker --net host option makes the host interfaces available in the container which is useful for some applications</li>
<li>When you deploy a pod with hostNetwork:true, it means the host network is reachable from the pod. By default when a pod is deployed (I verified this on my local machine using <a href="https://kind.sigs.k8s.io/" rel="nofollow noreferrer">Kind</a>) the host network is reachable. I can see the veth interface connected to the bridge on the host. Even with hostNetwork: false, I was able to update packages on my pod.So, not sure what to make out of this setting. At this stage, I am concluding that there is no option to expose the host interface directly on the pod.</li>
</ul>
