Lets say, you need to run a custom app listening on a fixed port on every worker node?, like a monitoring agent, here's my POC for the case:
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: monitor
spec:
updateStrategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
template:
metadata:
labels:
app: monitor-nginx
spec:
# nodeSelector:
# app: node-monitor-nginx
containers:
- name: node-monitor-nginx-container
image: nginx:alpine
ports:
- containerPort: 80
hostPort: 31179
protocol: TCP
Let's say that my agent reports node status on an nginx pod, so you can get the data on the TCP31179 on every node.
Why the pod it's not listening on that port on the worker nodes??
root@ip-10-0-1-109:~# telnet 10.0.1.109 31179
Trying 10.0.1.109...
telnet: Unable to connect to remote host: Connection refused
There is an issue about hostPort when CNI is used, you can find informative discussion in this GitHub issue.
Other then that, you might also look into hostNetwork: true
as a workaround.