• About Us
  • Privacy & Policy
HowTo's
  • Home
  • Commands
  • Linux
  • SCM
  • Git
  • Database
  • MySQL
  • Kubernetes
  • Docker
No Result
View All Result
  • Home
  • Commands
  • Linux
  • SCM
  • Git
  • Database
  • MySQL
  • Kubernetes
  • Docker
No Result
View All Result
HowTo's
No Result
View All Result
Home Kubernetes

Update Node Taints with kubectl taint

June 26, 2024
in Kubernetes, Kubernetes Commands Examples, Kubernetes Commands Tutorial, Kubernetes Tutorial
A A
0
11
SHARES
100
VIEWS
Share on FacebookShare on Twitter

The kubectl taint command in Kubernetes is used to update node taints, which are key-value pairs associated with nodes. Taints are used to repel certain pods from nodes unless the pods have corresponding tolerations. This helps in influencing pod placement decisions and ensuring that only suitable workloads are scheduled on specific nodes.

Let’s explore several examples of how to use kubectl taint:

Example 1: Add a taint to a node
To add a taint to a node named node1 with key app and value blue, use the following command:

kubectl taint nodes node1 app=blue:NoSchedule

Explanation: This command adds a taint with key app and value blue to node1. Pods without a matching toleration won’t be scheduled on this node. The NoSchedule effect indicates that pods will not be scheduled unless they tolerate this taint.

Example 2: Remove a taint from a node
To remove the taint with key app from node1, use:

kubectl taint nodes node1 app-

Explanation: This command removes the taint with key app from node1, allowing pods that previously couldn’t be scheduled due to this taint to now be considered for scheduling.

Example 3: View taints on a node
To view all taints on node1, use:

kubectl describe node node1 | grep Taints

Explanation: This command retrieves and displays all taints applied to node1. It uses kubectl describe to fetch detailed information about the node and then filters for the taints section.

Example 4: Add a taint to a node with effect and toleration
To add a taint with key special, value critical, effect NoExecute, and a pod toleration, use:

kubectl taint nodes node1 special=critical:NoExecute --overwrite

Explanation: This command adds a taint with the effect NoExecute, which evicts existing pods that do not tolerate it. The --overwrite flag ensures any existing taint with the same key is replaced.

Example 5: Add a taint to multiple nodes
To add the same taint to multiple nodes at once, create a YAML file like:

apiVersion: v1
kind: Node
metadata:
  name: node1
spec:
  taints:
  - key: special
    value: critical
    effect: NoSchedule
---
apiVersion: v1
kind: Node
metadata:
  name: node2
spec:
  taints:
  - key: special
    value: critical
    effect: NoSchedule

Apply it using:

kubectl apply -f filename.yaml

Explanation: This YAML file defines nodes node1 and node2 with the same taint. Applying it with kubectl apply updates the nodes accordingly.

To verify if a taint has been successfully added or removed from a node, you can re-describe the node and check the taints section. For example, after adding a taint, run:

kubectl describe node node1 | grep Taints

This will display the current taints on node1 and confirm if the operation was successful.

Also check similar articles.

Prepare Nodes for Maintenance with kubectl drain
Scheduling Nodes in Kubernetes with kubectl uncordon
How to Cordon Kubernetes Nodes with kubectl cordon
Monitor Resource Usage with kubectl top
Access Cluster Information Using kubectl cluster-info

Tags: KubernetesKubernetes Commands ExamplesKubernetes Commands TutorialKubernetes Tutorial
Previous Post

Prepare Nodes for Maintenance with kubectl drain

Next Post

Detailed Resource Inspection with kubectl describe

Related You may like!

howto

Interacting with Kubernetes Plugins using kubectl plugin

June 26, 2024
howto

Configuring kubectl and kubeconfig Files

June 26, 2024

Exploring Kubernetes API Versions with kubectl api-versions

June 26, 2024

Understanding Kubernetes API Resources with kubectl api-resources

June 26, 2024

Generating Shell Completion Code with kubectl completion

June 26, 2024

Managing Kubernetes Annotations with kubectl annotate

June 26, 2024
Next Post
howto

Detailed Resource Inspection with kubectl describe

howto

Retrieve Container Logs Using kubectl logs

howto

Attach to Running Containers with kubectl attach

Discussion about this post

Latest Updated

howto

How to Use -iname for Case-Insensitive Filename Searches in find

August 21, 2024
howto

Search for Files with Case-Insensitive Pattern Matching Using -ilname in find

August 21, 2024
howto

Find Files by Group Name with -group in find Command

August 21, 2024
howto

Locate Files by Group ID Using -gid in find Command

August 21, 2024
howto

How to Search for Filesystems with -fstype in find Command

August 21, 2024

Trending in Week

  • howto

    Using BTRFS Subvolume for User Home Directory in Linux

    22 shares
    Share 9 Tweet 6
  • Downloading Docker Images from a Registry

    13 shares
    Share 5 Tweet 3
  • Configuring SSL Connection Mode in mysqldump

    17 shares
    Share 7 Tweet 4
  • Omit Tablespace Information in mysqldump Output

    13 shares
    Share 5 Tweet 3
  • Setting MySQL Dump Compatibility Mode

    18 shares
    Share 7 Tweet 5
  • Setting Network Buffer Length in mysqldump

    13 shares
    Share 5 Tweet 3
  • Logging out from Docker Registries

    13 shares
    Share 5 Tweet 3
  • Scheduling Nodes in Kubernetes with kubectl uncordon

    12 shares
    Share 5 Tweet 3
  • Managing Default User Creation Settings in Linux

    15 shares
    Share 6 Tweet 4
  • Using Extended INSERT Syntax in mysqldump

    12 shares
    Share 5 Tweet 3
  • About Us
  • Privacy & Policy

© 2024 All Rights Reserved. Howto.swebtools.com.

No Result
View All Result

© 2024 All Rights Reserved. Howto.swebtools.com.