Scheduling and Tooling
- K8s Cluster can contain multiple nodes and workloads are scheduled on the node by kube-schedule and there are different factors influencing the decision to select the node
- node selector
- node affinity
- taints and tolerations
- Container Resource Limits influence this decision as kube-Scheduler will sum all the requests of container in a Pod spec and schedules it on a suitable node
- If the Pod doesnot schedule due to insufficient resources available on nodes in the Events we will see the following reasons
- PodExceedsFreeCpu
- PodExceedsFreeMemory
Node-Selector
- Refer Here for official docs
- Lets label two nodes
- node2:
- labels
- diskspeed=high
- labels
- node3:
- labels:
- diskspeed=low
- diskspeed=low
- labels:
- node2:
- Lets create a Pod and specify the selection based on diskspeed=high which has a match and one more pod which doesnot match. Refer Here for the changeset
- Pod will be scheduled on node matching labels but not on not matching scenarios
Node Affinity
- Refer Here for official docs
- Refer Here for nodeAffinity with hard and soft rules
- Non Matching hard will not be scheduled
- podAffinity speaks about running a pod on the same node as some other pod with matching conditions and reverse of it is podAntiAffinity
- Refer Here for the manifests
Taints and Tolerations
- Taint is a property of a node to repel the pods. Only pods who have toleration for the taint will be scheduled on the node.
- Usecases:
- Dedicated Hardware:
- Evictions
- Refer Here for official docs
- Taint Effects:
- NoSchedule
- NoExecute
- PreferNoShedule
- Taint nodes
kubectl taint nodes <node-name> <taint:key>=<taint:value>:<taint-effect>
Yaml Processor
- The tool
yq
is used to read, modify and enhance contents of YAML file. - Refer Here for the docs
- Exercise 1: Try more samples on modifying yaml files
- Exercise 2:
- Create a Deployment using nopCommerce Docker image
- Create a stateful set using mysql Container