Monday, August 05, 2019

Tip: ClusterFirst vs ClusterFirstWithHostNet in Kubernetes Pod DNS config

Symptom:

 We got below error when we start 2 pods in the same Host. 1pod starts successfully and 1 pod is on pending status , can't startup running.  Error is like below
0/2 nodes are available: 2 node(s) didn't have free ports for the requested pod ports.

Reason:

 We have 2 entries in the deployment yaml files.  It means the pod is using host network, the first pod uses the certain port and the 2nd pod can't use the same port in the host, thus we see above error. After we remove these 2 entries , restart deployment, the issue is fixed.  Default dnsPolicy is  ClusterFirst.  Refer pod dns config settings doc
dnsPolicy: ClusterFirstWithHostNet
hostNetwork: true


No comments: