Taints (on nodes) and Tolerations (on pods)
Understanding Taints on Nodes
To inspect taints on a specific node, use the following command:
kubectl describe node <node-name> | grep -i "taint"
Tainting a Node
Create a taint on a node with a specific key, value, and effect:
kubectl taint node <node-name> spray=mortein:NoSchedule
spray
: Key of the taint.
mortein
: Value associated with the key.
NoSchedule
: Effect that defines the behavior of pods that do not tolerate this taint.
Tolerations on Pods
When deploying pods, use tolerations to allow them to tolerate specific node taints. In the pod specification, add a tolerations section under spec with properties like key, operator, value, and effect:
#yaml
apiVersion: v1
kind: Pod
metadata:
name: mypod
spec:
tolerations:
- key: "spray"
operator: "Equal"
value: "mortein"
effect: "NoSchedule"
containers:
- name: mycontainer
image: myimage
Removing Taints
To remove a specific taint from a node:
kubectl taint node <node-name> key=value:effect-
For example, to remove all taints with key 'dedicated' from node 'foo':
kubectl taint node foo dedicated-
Logging
Viewing Container Logs
Check the standard output of a container using the logs command:
kubectl logs -f <pod-name> <container-name> # Follow the logs
kubectl logs <pod-name> --previous # Dump pod logs for a
previous instantiation of a container
Monitoring
Resource Usage Metrics
Get resource usage metrics for nodes and pods:
kubectl top node
kubectl top pod
Identifying CPU-Intensive Pod
To find the pod consuming the most CPU:
kubectl top pod --namespace=default | head -2 | tail -1 | cut -d " " -f1
kubectl top pod --sort-by cpu --no-headers
Empower your Kubernetes journey with insights into taints, tolerations, efficient logging, and real-time monitoring.
Happy Kuberneting!
Top comments (0)