Kubernetes : why is HostIP ignored in my pod manifest Kubernetes : why is HostIP ignored in my pod manifest kubernetes kubernetes

Kubernetes : why is HostIP ignored in my pod manifest


You have to add hostNetwork= true so it the pod will share host's network space.

For example you can deploy following manifest:

apiVersion: v1kind: Podmetadata:  name: secondpodspec:  containers:  - name: container    image: hashicorp/http-echo    args:      - "-text=banana"    ports:      - containerPort: 5678        hostIP: 10.156.0.46        hostPort: 5678  restartPolicy: Never  hostNetwork: true

Where 10.156.0.46 is my host's IP and once deployed:

$ kubectl get pod -o wideNAME        READY   STATUS    RESTARTS   AGE   IP               NODE     NOMINATED NODE   READINESS GATESsecondpod   1/1     Running   0          10m   10.156.0.46      worker   <none>           <none>

you can successfully curl it:

$ curl 10.156.0.46:5678banana