DevOps Interview: Replica sets vs Daemon sets
Replica sets and Daemon sets are controllers in Kubernetes used to manage the lifecycle of Pods. They are used to manage Pods.
Let's check the differences between them.
Replica sets ensure that a certain number of copies should be running on nodes. Daemon sets ensure exactly one copy running on all or certain nodes.
Replica sets can be scaled up or down by assigning "replicas" field in the manifest file. Daemon sets scales automatically when the node number changes.
Replica sets are used for stateless applications to maintain a certain number of instances of the application. Daemon sets are used for deploying backend services like monitoring agents, logging agents etc.
Let's see the manifest file for both.
Replica sets-
apiVersion: apps/v1 kind: ReplicaSet metadata: name: <any name> spec: replicas: <any number> selector: matchLabels: app: <any name> # any label based on your need template: metadata: labels: app: <webserver> spec: containers: - name: <any name> image: nginx:latest ports: - containerPort: 80
Daemon sets-
apiVersion: apps/v1 kind: DaemonSet metadata: name: <any name> spec: selector: matchLabels: app: < any name > # any label based on your need template: metadata: labels: app: < any name> spec: containers: - name: <any name> image: fluentd:latest volumeMounts: - name: < your volume name> mountPath: /var/log # any path directory on host volumes: - name: < your volume name> hostPath: path: /var/log # mounted volume on this path on host node
Example of Replica sets - any web application with certain replicas etc.
Example of Daemon sets - agent deployed to collect logs from nodes.
Still confused !!
No need to worry. Let’s take daily life example for both.
Replica sets-
In a restaurant, the waiters (replicas) form a ReplicaSet. The manager, acting as the controller, ensures enough waiters are available to serve customers efficiently. If a waiter is absent, the manager replaces them with another waiter to maintain the desired number of serving staff.
Daemon sets-
In a city with a fleet of garbage trucks, each truck (pod) is assigned a specific area (node) to collect trash. The fleet manager, acting as the DaemonSet, ensures a truck is always present in every area (node) for efficient waste management.
That’s all. Pat yourself on the back. :)
Hope you enjoyed it. Don’t forget to like it.
Subscribe to my newsletter
Read articles from Aishwary Prakash directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Aishwary Prakash
Aishwary Prakash
Hi Aspirants, my name is Aishwary Prakash and I'm a DevOps/ Site Reliability Engineer (SRE) with 4 years of experience. I'm passionate about using technology to solve real-world problems. In my current role, I'm responsible for the reliability, scalability, and performance of a large-scale cloud platform. I'm also interested in DevOps, monitoring, automation, fitness, cloud, and CI/CD. Some of the topics I write about include: SRE: I write about Site Reliability Engineering (SRE) best practices, tools, and technologies. DevOps: I write about DevOps practices, tools, and technologies that can help teams to deliver software more quickly and reliably. Monitoring: I write about monitoring tools and techniques that can be used to identify and resolve problems with software systems before they impact users. Automation: I write about automation tools and techniques that can be used to automate repetitive tasks, improve efficiency, and reduce errors. Fitness: I write about fitness tips, workouts, and nutrition advice that can help people to improve their overall health and well-being. Cloud: I write about cloud computing platforms, tools, and technologies that can be used to build and deploy scalable software systems. DevOps/SRE Interview: I write about DevOps/SRE related interview based on my experience and other professionals. I hope you enjoy my blog! Connect with me at aishwaryprakash98@gmail.com