From cae9b11262fa0c51500ed840208060ea80692109 Mon Sep 17 00:00:00 2001 From: Dhairya-Arora01 <90555081+Dhairya-Arora01@users.noreply.github.com> Date: Wed, 10 May 2023 07:28:59 +0530 Subject: [PATCH] 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 * Suggested changes * Update content/en/docs/tasks/manage-daemon/pods-some-nodes.md Co-authored-by: Rey Lejano * Update content/en/docs/tasks/manage-daemon/pods-some-nodes.md Co-authored-by: Tim Bannister * Update content/en/docs/tasks/manage-daemon/pods-some-nodes.md Co-authored-by: Tim Bannister * Update content/en/docs/tasks/manage-daemon/pods-some-nodes.md Co-authored-by: Tim Bannister * Update content/en/docs/tasks/manage-daemon/pods-some-nodes.md Co-authored-by: Tim Bannister --------- Co-authored-by: Nitish Kumar Co-authored-by: Rey Lejano Co-authored-by: Tim Bannister --- .../tasks/manage-daemon/pods-some-nodes.md | 61 +++++++++++++++++++ .../controllers/daemonset-label-selector.yaml | 20 ++++++ 2 files changed, 81 insertions(+) create mode 100644 content/en/docs/tasks/manage-daemon/pods-some-nodes.md create mode 100644 content/en/examples/controllers/daemonset-label-selector.yaml diff --git a/content/en/docs/tasks/manage-daemon/pods-some-nodes.md b/content/en/docs/tasks/manage-daemon/pods-some-nodes.md new file mode 100644 index 0000000000..987adf0d3b --- /dev/null +++ b/content/en/docs/tasks/manage-daemon/pods-some-nodes.md @@ -0,0 +1,61 @@ +--- +title: Running Pods on Only Some Nodes +content_type: task +weight: 30 +--- + + +This page demonstrates how can you run {{}} on only some {{}} as part of a {{}} + +## {{% heading "prerequisites" %}} + +{{< include "task-tutorial-prereqs.md" >}} + +## Running Pods on only some Nodes + +Imagine that you want to run a {{}}, 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 {{}} which will provision the daemon pods on the SSD labeled {{}} 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 + 1/1 Running 0 13s ..... example-node-1 + 1/1 Running 0 13s ..... example-node-2 + 1/1 Running 0 5s ..... example-node-3 +``` \ No newline at end of file diff --git a/content/en/examples/controllers/daemonset-label-selector.yaml b/content/en/examples/controllers/daemonset-label-selector.yaml new file mode 100644 index 0000000000..458e19ceb4 --- /dev/null +++ b/content/en/examples/controllers/daemonset-label-selector.yaml @@ -0,0 +1,20 @@ +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: ssd-driver + labels: + app: nginx +spec: + selector: + matchLabels: + app: ssd-driver-pod + template: + metadata: + labels: + app: ssd-driver-pod + spec: + nodeSelector: + ssd: "true" + containers: + - name: example-container + image: example-image \ No newline at end of file