Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

simulate Daemon-set in kubernetes with using Deployment

I'm trying to simulate Daemon-set in kubernetes with using Deployment/RC/Replica-set.

What I want to achieve :

As daemon-set kind deploy PODs on each nodes like wise I want to deploy pod on each node, but without kind daemonset.

Is there any way to do it ? Can't find proper way to do that.

like image 909
Nilesh Suryavanshi Avatar asked Feb 16 '26 01:02

Nilesh Suryavanshi


1 Answers

You can do that by using Deployment/ReplicaSet in Kubernetes with hostPort.

Assuming you have 4 nodes in Kubernetes cluster, you can create a deployment or replicaset with hostPort and replicas equal to number of nodes in cluster.

For example you want to run nginx pod on every node with clustersize equal to 4 then you have mention hostport to container port in deployment/replicaset definition. The kubernetes scheduler will be unable to schedule more than 1 pod on same host and in this way all nodes have at least one pod scheduled.

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx-hello
  labels:  
    tier: frontend
    app: nginx-hello
spec:
  replicas: 4
  template:
    metadata:
      labels:
        tier: frontend
        app: nginx-hello
    spec:
      containers:
      - name: nginx-hello
        image: nginxdemos/hello
        ports:
        - containerPort: 80
          hostPort: 8088
like image 173
gaurav9 Avatar answered Feb 18 '26 18:02

gaurav9