Skip to content

Commit cae9b11

Browse files
Dhairya-Arora01nitishfyreylejanoTim Bannister
authored
Created new task page - Running Pods on Only Some Nodes (#39972)
* Added pod-some-nodes in manage-daemon of taskks * Changedd the code file reference * Added the code ouput * Added the suggested changes * Update content/en/docs/tasks/manage-daemon/pods-some-nodes.md Co-authored-by: Nitish Kumar <[email protected]> * Suggested changes * Update content/en/docs/tasks/manage-daemon/pods-some-nodes.md Co-authored-by: Rey Lejano <[email protected]> * Update content/en/docs/tasks/manage-daemon/pods-some-nodes.md Co-authored-by: Tim Bannister <[email protected]> * Update content/en/docs/tasks/manage-daemon/pods-some-nodes.md Co-authored-by: Tim Bannister <[email protected]> * Update content/en/docs/tasks/manage-daemon/pods-some-nodes.md Co-authored-by: Tim Bannister <[email protected]> * Update content/en/docs/tasks/manage-daemon/pods-some-nodes.md Co-authored-by: Tim Bannister <[email protected]> --------- Co-authored-by: Nitish Kumar <[email protected]> Co-authored-by: Rey Lejano <[email protected]> Co-authored-by: Tim Bannister <[email protected]>
1 parent a32bff3 commit cae9b11

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
title: Running Pods on Only Some Nodes
3+
content_type: task
4+
weight: 30
5+
---
6+
<!-- overview -->
7+
8+
This page demonstrates how can you run {{<glossary_tooltip term_id="pod" text="Pods">}} on only some {{<glossary_tooltip term_id="node" text="Nodes">}} as part of a {{<glossary_tooltip term_id="daemonset" text="DaemonSet">}}
9+
10+
## {{% heading "prerequisites" %}}
11+
12+
{{< include "task-tutorial-prereqs.md" >}}
13+
14+
## Running Pods on only some Nodes
15+
16+
Imagine that you want to run a {{<glossary_tooltip term_id="daemonset" text="DaemonSet">}}, but you only need to run those daemon pods
17+
on nodes that have local solid state (SSD) storage. For example, the Pod might provide cache service to the
18+
node, and the cache is only useful when low-latency local storage is available.
19+
20+
### Step 1: Add labels to your nodes
21+
22+
Add the label `ssd=true` to the nodes which have SSDs.
23+
24+
```shell
25+
kubectl label nodes example-node-1 example-node-2 ssd=true
26+
```
27+
28+
### Step 2: Create the manifest
29+
30+
Let's create a {{<glossary_tooltip term_id="daemonset" text="DaemonSet">}} which will provision the daemon pods on the SSD labeled {{<glossary_tooltip term_id="node" text="nodes">}} only.
31+
32+
33+
Next, use a `nodeSelector` to ensure that the DaemonSet only runs Pods on nodes
34+
with the `ssd` label set to `"true"`.
35+
36+
{{<codenew file="controllers/daemonset-label-selector.yaml">}}
37+
38+
### Step 3: Create the DaemonSet
39+
40+
Create the DaemonSet from the manifest by using `kubectl create` or `kubectl apply`
41+
42+
Let's label another node as `ssd=true`.
43+
44+
```shell
45+
kubectl label nodes example-node-3 ssd=true
46+
```
47+
48+
Labelling the node automatically triggers the control plane (specifically, the DaemonSet controller)
49+
to run a new daemon pod on that node.
50+
51+
```shell
52+
kubectl get pods -o wide
53+
```
54+
The output is similar to:
55+
56+
```
57+
NAME READY STATUS RESTARTS AGE IP NODE
58+
<daemonset-name><some-hash-01> 1/1 Running 0 13s ..... example-node-1
59+
<daemonset-name><some-hash-02> 1/1 Running 0 13s ..... example-node-2
60+
<daemonset-name><some-hash-03> 1/1 Running 0 5s ..... example-node-3
61+
```
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: apps/v1
2+
kind: DaemonSet
3+
metadata:
4+
name: ssd-driver
5+
labels:
6+
app: nginx
7+
spec:
8+
selector:
9+
matchLabels:
10+
app: ssd-driver-pod
11+
template:
12+
metadata:
13+
labels:
14+
app: ssd-driver-pod
15+
spec:
16+
nodeSelector:
17+
ssd: "true"
18+
containers:
19+
- name: example-container
20+
image: example-image

0 commit comments

Comments
 (0)