Skip to content

Commit 9f37676

Browse files
kow3nssteveperry-53
authored andcommitted
update DaemonSet concept for 1.8 release (#5397)
* update DaemonSet concept for 1.8 release * Update daemonset.md Fix typo. than -> then
1 parent a10da9c commit 9f37676

File tree

2 files changed

+64
-49
lines changed

2 files changed

+64
-49
lines changed

docs/concepts/workloads/controllers/daemonset.md

Lines changed: 59 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
---
22
approvers:
3+
- enisoc
34
- erictune
5+
- foxish
6+
- janetkuo
7+
- kow3ns
48
title: Daemon Sets
59
---
610

@@ -9,9 +13,9 @@ title: Daemon Sets
913

1014
## What is a DaemonSet?
1115

12-
A _DaemonSet_ ensures that all (or some) nodes run a copy of a pod. As nodes are added to the
13-
cluster, pods are added to them. As nodes are removed from the cluster, those pods are garbage
14-
collected. Deleting a DaemonSet will clean up the pods it created.
16+
A _DaemonSet_ ensures that all (or some) Nodes run a copy of a Pod. As nodes are added to the
17+
cluster, Pods are added to them. As nodes are removed from the cluster, those Pods are garbage
18+
collected. Deleting a DaemonSet will clean up the Pods it created.
1519

1620
Some typical uses of a DaemonSet are:
1721

@@ -47,20 +51,26 @@ A DaemonSet also needs a [`.spec`](https://git.k8s.io/community/contributors/dev
4751

4852
### Pod Template
4953

50-
The `.spec.template` is the only required field of the `.spec`.
54+
The `.spec.template` is one of the required fields in `.spec`.
5155

52-
The `.spec.template` is a [pod template](/docs/concepts/workloads/pods/pod-overview/#pod-templates). It has exactly the same schema as a [pod](/docs/concepts/workloads/pods/pod/), except it is nested and does not have an `apiVersion` or `kind`.
56+
The `.spec.template` is a [pod template](/docs/concepts/workloads/pods/pod-overview/#pod-templates). It has exactly the same schema as a [Pod](/docs/concepts/workloads/pods/pod/), except it is nested and does not have an `apiVersion` or `kind`.
5357

54-
In addition to required fields for a pod, a pod template in a DaemonSet has to specify appropriate
58+
In addition to required fields for a Pod, a Pod template in a DaemonSet has to specify appropriate
5559
labels (see [pod selector](#pod-selector)).
5660

57-
A pod template in a DaemonSet must have a [`RestartPolicy`](/docs/user-guide/pod-states)
61+
A Pod Template in a DaemonSet must have a [`RestartPolicy`](/docs/user-guide/pod-states)
5862
equal to `Always`, or be unspecified, which defaults to `Always`.
5963

6064
### Pod Selector
6165

6266
The `.spec.selector` field is a pod selector. It works the same as the `.spec.selector` of
63-
a [Job](/docs/concepts/jobs/run-to-completion-finite-workloads/) or other new resources.
67+
a [Job](/docs/concepts/jobs/run-to-completion-finite-workloads/).
68+
69+
As of Kubernetes 1.8, you must specify a pod selector that matches the labels of the
70+
`.spec.template`. The pod selector will no longer be defaulted when left empty. Selector
71+
defaulting was not compatible with `kubectl apply`. Also, once a DaemonSet is created,
72+
its `spec.selector` can not be mutated. Mutating the pod selector can lead to the
73+
unintentional orphaning of Pods, and it was found to be confusing to users.
6474

6575
The `spec.selector` is an object consisting of two fields:
6676

@@ -73,32 +83,34 @@ When the two are specified the result is ANDed.
7383
If the `.spec.selector` is specified, it must match the `.spec.template.metadata.labels`. If not
7484
specified, they are defaulted to be equal. Config with these not matching will be rejected by the API.
7585

76-
Also you should not normally create any pods whose labels match this selector, either directly, via
77-
another DaemonSet, or via other controller such as ReplicationController. Otherwise, the DaemonSet
78-
controller will think that those pods were created by it. Kubernetes will not stop you from doing
79-
this. One case where you might want to do this is manually create a pod with a different value on
86+
Also you should not normally create any Pods whose labels match this selector, either directly, via
87+
another DaemonSet, or via other controller such as ReplicaSet. Otherwise, the DaemonSet
88+
controller will think that those Pods were created by it. Kubernetes will not stop you from doing
89+
this. One case where you might want to do this is manually create a Pod with a different value on
8090
a node for testing.
8191

92+
If you attempt to create a DaemonSet such that
93+
8294
### Running Pods on Only Some Nodes
8395

8496
If you specify a `.spec.template.spec.nodeSelector`, then the DaemonSet controller will
85-
create pods on nodes which match that [node
97+
create Pods on nodes which match that [node
8698
selector](/docs/concepts/configuration/assign-pod-node/). Likewise if you specify a `.spec.template.spec.affinity`,
87-
then DaemonSet controller will create pods on nodes which match that [node affinity](/docs/concepts/configuration/assign-pod-node/).
88-
If you do not specify either, then the DaemonSet controller will create pods on all nodes.
99+
then DaemonSet controller will create Pods on nodes which match that [node affinity](/docs/concepts/configuration/assign-pod-node/).
100+
If you do not specify either, then the DaemonSet controller will create Pods on all nodes.
89101

90102
## How Daemon Pods are Scheduled
91103

92-
Normally, the machine that a pod runs on is selected by the Kubernetes scheduler. However, pods
93-
created by the Daemon controller have the machine already selected (`.spec.nodeName` is specified
94-
when the pod is created, so it is ignored by the scheduler). Therefore:
104+
Normally, the machine that a Pod runs on is selected by the Kubernetes scheduler. However, Pods
105+
created by the DaemonSet controller have the machine already selected (`.spec.nodeName` is specified
106+
when the Pod is created, so it is ignored by the scheduler). Therefore:
95107

96108
- The [`unschedulable`](/docs/admin/node/#manual-node-administration) field of a node is not respected
97109
by the DaemonSet controller.
98-
- DaemonSet controller can make pods even when the scheduler has not been started, which can help cluster
110+
- The DaemonSet controller can make Pods even when the scheduler has not been started, which can help cluster
99111
bootstrap.
100112

101-
Daemon pods do respect [taints and tolerations](/docs/concepts/configuration/assign-pod-node/#taints-and-tolerations-beta-feature),
113+
Daemon Pods do respect [taints and tolerations](/docs/concepts/configuration/assign-pod-node/#taints-and-tolerations-beta-feature),
102114
but they are created with `NoExecute` tolerations for the following taints with no `tolerationSeconds`:
103115

104116
- `node.alpha.kubernetes.io/notReady`
@@ -122,32 +134,32 @@ Note that all above `NoSchedule` taints above are created only in version 1.8 or
122134

123135
## Communicating with Daemon Pods
124136

125-
Some possible patterns for communicating with pods in a DaemonSet are:
137+
Some possible patterns for communicating with Pods in a DaemonSet are:
126138

127139
- **Push**: Pods in the DaemonSet are configured to send updates to another service, such
128140
as a stats database. They do not have clients.
129-
- **NodeIP and Known Port**: Pods in the DaemonSet can use a `hostPort`, so that the pods are reachable via the node IPs. Clients know the list of node IPs somehow, and know the port by convention.
130-
- **DNS**: Create a [headless service](/docs/user-guide/services/#headless-services) with the same pod selector,
141+
- **NodeIP and Known Port**: Pods in the DaemonSet can use a `hostPort`, so that the Pods are reachable via the node IPs. Clients know the list of node IPs somehow, and know the port by convention.
142+
- **DNS**: Create a [headless service](/docs/user-guide/services/#headless-services) with the same Pod selector,
131143
and then discover DaemonSets using the `endpoints` resource or retrieve multiple A records from
132144
DNS.
133-
- **Service**: Create a service with the same pod selector, and use the service to reach a
145+
- **Service**: Create a service with the same Pod selector, and use the service to reach a
134146
daemon on a random node. (No way to reach specific node.)
135147

136148
## Updating a DaemonSet
137149

138-
If node labels are changed, the DaemonSet will promptly add pods to newly matching nodes and delete
139-
pods from newly not-matching nodes.
150+
If node labels are changed, the DaemonSet will promptly add Pods to newly matching nodes and delete
151+
Pods from newly not-matching nodes.
140152

141-
You can modify the pods that a DaemonSet creates. However, pods do not allow all
153+
You can modify the Pods that a DaemonSet creates. However, Pods do not allow all
142154
fields to be updated. Also, the DaemonSet controller will use the original template the next
143155
time a node (even with the same name) is created.
144156

145157

146-
You can delete a DaemonSet. If you specify `--cascade=false` with `kubectl`, then the pods
158+
You can delete a DaemonSet. If you specify `--cascade=false` with `kubectl`, then the Pods
147159
will be left on the nodes. You can then create a new DaemonSet with a different template.
148-
the new DaemonSet with the different template will recognize all the existing pods as having
149-
matching labels. It will not modify or delete them despite a mismatch in the pod template.
150-
You will need to force new pod creation by deleting the pod or deleting the node.
160+
The new DaemonSet with the different template will recognize all the existing Pods as having
161+
matching labels. It will not modify or delete them despite a mismatch in the Pod template.
162+
You will need to force new Pod creation by deleting the Pod or deleting the node.
151163

152164
In Kubernetes version 1.6 and later, you can [perform a rolling update](/docs/tasks/manage-daemon/update-daemon-set/) on a DaemonSet.
153165

@@ -162,35 +174,35 @@ It is certainly possible to run daemon processes by directly starting them on a
162174
running such processes via a DaemonSet:
163175

164176
- Ability to monitor and manage logs for daemons in the same way as applications.
165-
- Same config language and tools (e.g. pod templates, `kubectl`) for daemons and applications.
177+
- Same config language and tools (e.g. Pod templates, `kubectl`) for daemons and applications.
166178
- Future versions of Kubernetes will likely support integration between DaemonSet-created
167-
pods and node upgrade workflows.
179+
Pods and node upgrade workflows.
168180
- Running daemons in containers with resource limits increases isolation between daemons from app
169-
containers. However, this can also be accomplished by running the daemons in a container but not in a pod
181+
containers. However, this can also be accomplished by running the daemons in a container but not in a Pod
170182
(e.g. start directly via Docker).
171183

172184
### Bare Pods
173185

174-
It is possible to create pods directly which specify a particular node to run on. However,
175-
a DaemonSet replaces pods that are deleted or terminated for any reason, such as in the case of
186+
It is possible to create Pods directly which specify a particular node to run on. However,
187+
a DaemonSet replaces Pods that are deleted or terminated for any reason, such as in the case of
176188
node failure or disruptive node maintenance, such as a kernel upgrade. For this reason, you should
177-
use a DaemonSet rather than creating individual pods.
189+
use a DaemonSet rather than creating individual Pods.
178190

179191
### Static Pods
180192

181-
It is possible to create pods by writing a file to a certain directory watched by Kubelet. These
193+
It is possible to create Pods by writing a file to a certain directory watched by Kubelet. These
182194
are called [static pods](/docs/concepts/cluster-administration/static-pod/).
183-
Unlike DaemonSet, static pods cannot be managed with kubectl
184-
or other Kubernetes API clients. Static pods do not depend on the apiserver, making them useful
185-
in cluster bootstrapping cases. Also, static pods may be deprecated in the future.
195+
Unlike DaemonSet, static Pods cannot be managed with kubectl
196+
or other Kubernetes API clients. Static Pods do not depend on the apiserver, making them useful
197+
in cluster bootstrapping cases. Also, static Pods may be deprecated in the future.
186198

187-
### Replication Controller
199+
### Deployments
188200

189-
DaemonSet are similar to [Replication Controllers](/docs/user-guide/replication-controller) in that
190-
they both create pods, and those pods have processes which are not expected to terminate (e.g. web servers,
201+
DaemonSets are similar to [Deployments](/docs/concepts/workloads/controllers/deployment.md) in that
202+
they both create Pods, and those Pods have processes which are not expected to terminate (e.g. web servers,
191203
storage servers).
192204

193-
Use a replication controller for stateless services, like frontends, where scaling up and down the
205+
Use a Deployment for stateless services, like frontends, where scaling up and down the
194206
number of replicas and rolling out updates are more important than controlling exactly which host
195-
the pod runs on. Use a Daemon Controller when it is important that a copy of a pod always run on
196-
all or certain hosts, and when it needs to start before other pods.
207+
the Pod runs on. Use a DaemonSet when it is important that a copy of a Pod always run on
208+
all or certain hosts, and when it needs to start before other Pods.

docs/concepts/workloads/controllers/daemonset.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
apiVersion: extensions/v1beta1
1+
apiVersion: apps/v1beta2
22
kind: DaemonSet
33
metadata:
44
name: fluentd-elasticsearch
55
namespace: kube-system
66
labels:
77
k8s-app: fluentd-logging
88
spec:
9+
selector:
10+
matchLabels:
11+
name: fluentd-elasticsearch
912
template:
1013
metadata:
1114
labels:
@@ -33,4 +36,4 @@ spec:
3336
path: /var/log
3437
- name: varlibdockercontainers
3538
hostPath:
36-
path: /var/lib/docker/containers
39+
path: /var/lib/docker/containers

0 commit comments

Comments
 (0)