问题描述
在Kelsey Hightower的Kubernetes Up and Running中,他给出了两个命令:
In Kelsey Hightower's Kubernetes Up and Running, he gives two commands :
kubectl get daemonSets --namespace=kube-system kube-proxy
和
kubectl get deployments --namespace=kube-system kube-dns
为什么一个使用daemonSets,而另一个使用?和有什么区别?
Why does one use daemonSets and the other deployments?And what's the difference?
推荐答案
Kubernetes部署管理在群集上运行的无状态服务(例如,管理状态服务的StatefulSet相对).他们的目的是保持一组相同的Pod运行并以受控方式对其进行升级.例如,您在部署定义中定义要运行多少个应用程序副本(pods
),而kubernetes将使应用程序的许多副本分布在节点上.如果您说5个副本超过3个节点,则某些节点正在运行您的应用程序的多个副本.
Kubernetes deployments manage stateless services running on your cluster (as opposed to for example StatefulSets which do 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
) you want to run of your app in deployment definition and kubernetes will make that many replicas of your application spread over nodes. If you say 5 replica's over 3 node then some nodes have more than one replica of your app running.
DaemonSets 管理复制的Pod组.但是,DaemonSets尝试在整个集群或节点子集上遵循每个节点一个Pod的模型.守护程序在每个节点上最多可以运行一个副本.使用Daemonset的另一个优点是,如果将节点添加到集群,则Daemonset将自动在该节点上生成pod,而部署不会这样做.
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. Daemonset will not run more than one replica per node. Another advantage of using Daemonset is, If you add a node to the cluster then Daemonset will automatically spawn pod on that node, which deployment will not do.
DaemonSets
对于部署需要在所有或某些节点上运行且不需要用户干预的正在进行的后台任务很有用.此类任务的示例包括诸如ceph
的存储守护程序,诸如fluentd
的日志收集守护程序以及诸如collectd
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
让我们以您提到的示例为例,为什么kube-dns
是部署而kube-proxy
是守护程序?
Lets take example you mentioned in question, why kube-dns
is deployment and kube-proxy
is daemonset?
在群集中的每个节点上都需要kube-proxy
来运行IP表,以使每个节点都可以访问每个Pod,无论它位于哪个节点上.因此,当我们将kube-proxy
设置为daemonset
并在稍后将另一个节点添加到集群时,会自动在该节点上生成kube-proxy.
The reason behind that is kube-proxy
is needed on every node in 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 cluster at later time kube-proxy is automatically spawned on that node.
Kube-dns
的责任是使用其名称发现服务IP,即使kube-dns
的一个副本也足以将服务名称解析为其IP,因此我们将kube-dns
设为deployment
,因为我们不这样做每个节点上都需要kube-dns
.
Kube-dns
responsibility is to discover the service IP using its name and even one replica of kube-dns
is enough to resolve the service name to its IP and hence we make kube-dns
a deployment
because we don't need kube-dns
on every node.
这篇关于守护程序集与部署之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!