MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

Update the taints on one or more nodes in Kubernetes

What is meaning of taint?

a trace of a bad or undesirable substance or quality.

What is tainted?

spoiled; damaged in quality, taste, or value:

Follwing are workload which run in a cluster’s node….

  • DaemonSet
  • Deployment
  • Pod
  • ReplicaSet
  • ReplicationController
  • StatefulSet

When you submit a workload, The scheduler determines where to place the Pods associated with the workload. The scheduler is free to place a Pod on any node that satisfies the Pod’s CPU, memory, and custom resource requirements.

If your cluster runs a variety of workloads, you might want to exercise some control over which workloads can run on a particular pool of nodes.

A node taint lets you mark a node so that the scheduler avoids or prevents using it for certain Pods. A complementary feature, tolerations, lets you designate Pods that can be used on “tainted” nodes.

A taint consists of a key, value, and effect. As an argument here, it is expressed as key=value:effect.

The key must begin with a letter or number, and may contain letters, numbers, hyphens, dots, and underscores, up to 253 characters. The value is optional. If given, it must begin with a letter or number, and may contain letters, numbers, hyphens, dots, and underscores, up to 63 characters.

The effect must be NoSchedule, PreferNoSchedule or NoExecute. Currently taint can only apply to node. Here are the available effects:

  • NoSchedule: Pods that do not tolerate this taint are not scheduled on the node.
  • PreferNoSchedule: Kubernetes avoids scheduling Pods that do not tolerate this taint onto the node.
  • NoExecute: Pod is evicted from the node if it is already running on the node, and is not scheduled onto the node if it is not yet running on the node.

Adding / Inspecting / Removing a taint to an existing node using NoSchedule


# Update node 'node1' with a taint with key 'dedicated' and value 'special-user' and effect 'NoSchedule'.
# Adding a taint to an existing node using NoSchedule
$ kubectl taint nodes node1 dedicated=special-user:NoScheduleCode language: PHP (php)

Inspecting a node’s taints


$ kubectl describe nodes node1 | grep -i taint
$ kubectl run nginx --image=nginx --replicas=8
$ kubectl get pod -o wideCode language: JavaScript (javascript)

Removing a taint from a node. Remove from node ‘node1’ the taint with key ‘dedicated’ and effect ‘NoSchedule’ if one exists.


$ kubectl taint nodes node1 dedicated:NoSchedule-
$ kubectl taint nodes ip-172-31-24-84.ap-south-1.compute.internal node-role.kubernetes.io/master:NoSchedule-

Adding / Inspecting / Removing a taint to an existing node using PreferNoSchedule


Add a taint with key 'dedicated' on nodes having label mylabel=X
$ kubectl taint node -l myLabel=X  dedicated=foo:PreferNoSchedule
$ kubectl taint node node1 dedicated=foo:PreferNoSchedule

Inspecting a node's taints
$ kubectl describe nodes node1 | grep -i taint
$ kubectl run nginx --image=nginx --replicas=8
$ kubectl get pod -o wide

Removing a taint from a node
$ kubectl taint nodes node1 dedicated:PreferNoSchedule-Code language: PHP (php)

Adding / Inspecting / Removing a taint to an existing node using NoExecute


$ kubectl taint nodes node2 node2=DoNotSchedulePods:NoExecute

Inspecting a node's taints
$ kubectl describe nodes node2 | grep Taint
# Because of that, all the pods on node2 are terminated and created on node3.
$ kubectl run nginx --image=nginx --replicas=8
$ kubectl get pod -o wide

Removing a taint from a node
$ kubectl taint nodes node2 node2:NoExecute-
$ kubectl describe nodes node2 | grep Taint

# Add to node 'foo' a taint with key 'bar' and no value
$ kubectl taint nodes foo bar:NoSchedule

Let’s verify the status of Taints on Master Node.
$ kubectl describe nodes node1 | grep Taints
Taints:             node-role.kubernetes.io/master:NoScheduleCode language: PHP (php)

Untaint the node and verify as below:


$ kubectl taint nodes --all node-role.kubernetes.io/master-
$ kubectl describe nodes node1 | grep -i taint

Run Test deployment in Untaint Node
$ kubectl run testsvr --image=nginx --replicas=7
$ kubectl get pods -o wide | grep testsvrCode language: JavaScript (javascript)

Untaint the setting on node2


$ kubectl taint nodes node3 node3=DoNotSchedulePods:NoSchedule
$ kubectl describe nodes node3 | grep Taint
$ kubectl run nginx --image=nginx --replicas=8

By default, kubernetes cluster will not schedule pods on the master node for security reasons. But if we would like to be able to schedule pods on the master node, e.g: for a single-node kubernetes cluster for testing and development purposes, we can run following commands.

$ kubectl taint nodes ip-172-31-24-84.ap-south-1.compute.internal node-role.kubernetes.io/master:NoSchedule-

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

Kubernetes Pod Explained: API Resource, YAML Example, and Use Cases

Birth Events of PODS Example of POD? Commads for working with POD? pod.yaml deployment.yaml How to use & troubleshoot Kubernetes pods? Troubleshooting and Debugging Commands: explain Documentation…

Read More

Kubernetes: How to Run a Pod and Get the EGRESS IP Address KubernetesEKS

1. Deploy a Pod to Your Cluster You can launch a simple Pod using the kubectl run command. For example, to run an NGINX Pod: bashkubectl run…

Read More

Kubernetes Troubleshooting: Pods in Pending – Causes & Fixes

Below is a complete, production-grade list of all common reasons why a Kubernetes pod stays in Pending state, along with detailed solutions, commands, and how to verify…

Read More

Troubleshooting Guide to Resolving 500 Errors in Kubernetes Production Environments

Source – https://github.com/rajeshkumarin/k8s-500-prod-issues 📘 Scenario #1: Zombie Pods Causing NodeDrain to HangCategory: Cluster ManagementEnvironment: K8s v1.23, On-prem bare metal, Systemd cgroupsScenario Summary: Node drain stuck indefinitely due…

Read More

𝑼𝒏𝒅𝒆𝒓𝒔𝒕𝒂𝒏𝒅𝒊𝒏𝒈 𝑲𝒖𝒃𝒆𝒓𝒏𝒆𝒕𝒆𝒔 𝑷𝒐𝒅 𝒇𝒂𝒊𝒍𝒖𝒓𝒆𝒔

Pods can have startup and runtime errors. Startup errors include: ✅ ImagePullBackoff✅ ImageInspectError✅ ErrImagePull✅ ErrImageNeverPull✅ RegistryUnavailable✅ InvalidImageName Runtime errors include: 📌 ✅ CrashLoopBackOff✅ RunContainerError✅ KillContainerError✅ VerifyNonRootError✅ RunInitContainerError✅…

Read More

What is Kubernetes Static Pods with example?

Static Pods are a special type of Pod in Kubernetes that are managed directly by the kubelet daemon on a specific node, without the API server observing…

Read More