⎈ k8s knowledge compiler

Running Pods on Only Some Nodes [page]deterministic

tasks

This page demonstrates how can you run [Pods](#gloss:pod) on only some [Nodes](#gloss:node) as part of a [DaemonSet](#gloss:daemonset)

##

## Running Pods on only some Nodes

Imagine that you want to run a [DaemonSet](#gloss:daemonset), but you only need to run those daemon pods on nodes that have local solid state (SSD) storage. For example, the Pod might provide cache service to the node, and the cache is only useful when low-latency local storage is available.

### Step 1: Add labels to your nodes

Add the label `ssd=true` to the nodes which have SSDs.

```shell kubectl label nodes example-node-1 example-node-2 ssd=true ```

### Step 2: Create the manifest

Let's create a [DaemonSet](#gloss:daemonset) which will provision the daemon pods on the SSD labeled [nodes](#gloss:node) only.

Next, use a `nodeSelector` to ensure that the DaemonSet only runs Pods on nodes with the `ssd` label set to `"true"`.

### Step 3: Create the DaemonSet

Create the DaemonSet from the manifest by using `kubectl create` or `kubectl apply`

Let's label another node as `ssd=true`.

```shell kubectl label nodes example-node-3 ssd=true ```

Labelling the node automatically triggers the control plane (specifically, the DaemonSet controller) to run a new daemon pod on that node.

```shell kubectl get pods -o wide ``` The output is similar to:

``` NAME READY STATUS RESTARTS AGE IP NODE <daemonset-name><some-hash-01> 1/1 Running 0 13s ..... example-node-1 <daemonset-name><some-hash-02> 1/1 Running 0 13s ..... example-node-2 <daemonset-name><some-hash-03> 1/1 Running 0 5s ..... example-node-3 ```

Sources

tasks/manage-daemon/pods-some-nodes.md · docRunning Pods on Only Some Nodes

Related (9)

references PodPods conf=1
references NodeNodes conf=1
references DaemonSetDaemonSet conf=1
part_of {{% heading "prerequisites" %}}describes conf=1
part_of Running Pods on only some Nodesdescribes conf=1
part_of Step 1: Add labels to your nodesdescribes conf=1
part_of Step 2: Create the manifestdescribes conf=1
part_of Step 3: Create the DaemonSetdescribes conf=1
api_for Nodedocuments API object conf=1

← all Docs