Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes daemonset listen specific port

Tags:

kubernetes

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
like image 698
ssebbass Avatar asked Nov 15 '25 15:11

ssebbass


1 Answers

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.

like image 124
Radek 'Goblin' Pieczonka Avatar answered Nov 17 '25 08:11

Radek 'Goblin' Pieczonka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!