From what I understand from the documentation (though it is not quite clear) , the hostIP:hostPort couple can be used to expose a container in a cluster (meaning, other pods/services in the cluster can access my container via hostIP:hostPort). am I getting it right?
However, when I deploy a pod like this one for instance :
apiVersion: v1
kind: Pod
metadata:
  name: firstpod
spec:
  containers:
  - name: container
    image: hashicorp/http-echo
    args:
      - "-text=banana"
    ports:
      - containerPort: 5678
        hostIP: 192.168.150.201
        hostPort: 5678
  restartPolicy: Never
  terminationGracePeriodSeconds: 0Where 192.168.150.201 is the ip address of a node in my cluster (lets call it node1) Most often, my pod does not get scheduled on node1. Evenmore, When I "force the pod to be scheduled on node1 (with nodeName for instance) I cant curl my app on hostIP:hostPort i.e.
curl 192.168.150.201:5678
curl: (7) Failed to connect to 192.168.150.201 port 5678: Connection refusedI have checked my pod is up and running (10.38.0.14 is firstpod ip address)
# curl 10.38.0.14:5678
banana
Any ideas?
You have to add hostNetwork= true so it the pod will share host's network space.
For example you can deploy following manifest:
apiVersion: v1
kind: Pod
metadata:
  name: secondpod
spec:
  containers:
  - name: container
    image: hashicorp/http-echo
    args:
      - "-text=banana"
    ports:
      - containerPort: 5678
        hostIP: 10.156.0.46
        hostPort: 5678
  restartPolicy: Never
  hostNetwork: trueWhere 10.156.0.46 is my host's IP and once deployed:
$ kubectl get pod -o wide
NAME        READY   STATUS    RESTARTS   AGE   IP               NODE     NOMINATED NODE   READINESS GATES
secondpod   1/1     Running   0          10m   10.156.0.46      worker   <none>           <none>
you can successfully curl it:
$ curl 10.156.0.46:5678
banana