Scheduler
- By default Pods gets scheduled based on node availability for the scheduler
- There may be cases where in one of the node has more resources and the pod required to be scheduled on this node
- There are two ways to achieve this
- Node Selector
- Node Affinity
Node Selector
- Update the pod definition file with the node selector label
- Pod will be scheduled on the node matching the label
- But first, Node has to be labelled.
- Within the pod definition spec.nodeSelector is the property to map a pod to a node
- With node selector, you can only have a simple key-value selection
- There are no options for advanced selectors like label in certain values, or label not-in a value
pod-definition.yaml
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
labels:
app: myapp
spec:
containers:
- name: nginx-container
image: nginx
nodeSelector:
size: Large
kubectl label node <node-name> <label-key>=<label-value>
-> Set a node label with key value pair
kubectl label node node01 size=Large
-> Set node01 label size to Large value
Comments
Post a Comment