kubernetes replicas in a daemonset

2/7/2019

I've got logstash running within 5 pods.

I cannot get the command to change the number of pods to 2 to work:

kuberctl scale --replicas=2 daemonset/logstash -n logstash

I have tried variations of it but still no joy.

Could someone tell or point me in the direction?

-- mac
kubernetes
kubernetes-health-check

2 Answers

2/7/2019

A DaemonSet ensures that all (or some) Nodes run a copy of a Pod. You can not control its replica using scale option. You have to use node selector to control replicas.You need to specify 2 nodes on which you want lagstash should run using node selector, so pods will be scheduled on those two nodes only.

Refer below code and add node selector to your pod configuration:

nodeSelector:
  logstash_allow: true

and add label logstash_allow: true to your two nodes on which you want lagstash

-- Rajesh Deshpande
Source: StackOverflow

2/7/2019

note that DaemonSet deploys one pod per node. the number of pods would be as many as nodes. you cant control the number of replicas.

you need to change the object to either Deployment or Statefulset to manage the replica count

-- P Ekambaram
Source: StackOverflow