Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between daemonsets and deployments

Tags:

kubernetes

In Kelsey Hightower's Kubernetes Up and Running, he gives two commands :

kubectl get daemonSets --namespace=kube-system kube-proxy

and

kubectl get deployments --namespace=kube-system kube-dns

Why does one use daemonSets and the other deployments? And what's the difference?

like image 385
Snowcrash Avatar asked Dec 21 '18 17:12

Snowcrash


People also ask

What is difference between deployment and stateful state?

Deployments are used for stateless applications, StatefulSets for stateful applications. The pods in a deployment are interchangeable, whereas the pods in a StatefulSet are not. Deployments require a service to enable interaction with pods, while a headless service handles the pods' network ID in StatefulSets.

What is the difference between ReplicaSet and deployment?

A ReplicaSet ensures that a specified number of pod replicas are running at any given time. However, a Deployment is a higher-level concept that manages ReplicaSets and provides declarative updates to Pods along with a lot of other useful features.

What is the difference between deployments and pods?

Their Role in Building and Managing Software As we now know, a pod is the smallest unit of Kubernetes used to house one or more containers and run applications in a cluster, while deployment is a tool that manages the performance of a pod.

What is difference between DaemonSet and StatefulSet?

Statefulsets is used for Stateful applications, each replica of the pod will have its own state, and will be using its own Volume. DaemonSet is a controller similar to ReplicaSet that ensures that the pod runs on all the nodes of the cluster.


Video Answer


1 Answers

Kubernetes deployments manage stateless services running on your cluster (as opposed to for example StatefulSets which manage stateful services). Their purpose is to keep a set of identical pods running and upgrade them in a controlled way. For example, you define how many replicas(pods) of your app you want to run in the deployment definition and kubernetes will make that many replicas of your application spread over nodes. If you say 5 replica's over 3 nodes, then some nodes will have more than one replica of your app running.

DaemonSets manage groups of replicated Pods. However, DaemonSets attempt to adhere to a one-Pod-per-node model, either across the entire cluster or a subset of nodes. A Daemonset will not run more than one replica per node. Another advantage of using a Daemonset is that, if you add a node to the cluster, then the Daemonset will automatically spawn a pod on that node, which a deployment will not do.

DaemonSets are useful for deploying ongoing background tasks that you need to run on all or certain nodes, and which do not require user intervention. Examples of such tasks include storage daemons like ceph, log collection daemons like fluentd, and node monitoring daemons like collectd

Lets take the example you mentioned in your question: why iskube-dns a deployment andkube-proxy a daemonset?

The reason behind that is that kube-proxy is needed on every node in the cluster to run IP tables, so that every node can access every pod no matter on which node it resides. Hence, when we make kube-proxy a daemonset and another node is added to the cluster at a later time, kube-proxy is automatically spawned on that node.

Kube-dns responsibility is to discover a service IP using its name and only one replica of kube-dns is enough to resolve the service name to its IP. Hence we make kube-dns a deployment, because we don't need kube-dns on every node.

like image 164
Prafull Ladha Avatar answered Nov 08 '22 00:11

Prafull Ladha