Scheduling
---------------
- manual scheduling
- daemon sets
- Labels and selectors
- Multiple schedulers
- Resource limits
- Configure kubernetes scheduler
Manually scheduling a POD
----------------------------------
how scheduling works?
Here, is a POD definition file.
# cat pod-definition-file.yaml
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
labels:
app: myapp
type: front-end-service
sepc:
containers:
- name: nginx-container
image: nginx:1.19
ports:
- containerPort: 8080
nodeName:
we have our pod definition file.
here we don't have nodeName: part. that mean nodeName is not defined
We normally do not specify this field when we create this definition file.
kubernetes adds it automatically.
scheduler goes through all the pods and looks for those pods who do not have that
property set.
These are the candidate for scheduling then identify the right node for the POD by
running the scheduling algorithm. Once identified, it schedules the pod on the node,
by setting the node name property to the name of the node by creating a binding object.
so what happens if there is no scheduler to monitor the nodes.
-> POD continue to be on pending state.
# kc get pods
so, what can you do about it?
You can manually assign pod to node yourself.
without a scheduler, easier way to schedule a POD is to simply set the node name field to the name of the node.
in your pod specification file while creating a POD. The POD is assigned to specified node.
You can only specify the node name at creation time.
What if node is already created and you want to assign pod to a node?
,-> Kubernetes won't allow you to modify the node name property of a node name.
Other way to assign a node to an existing POD is to create a binding object and send a post request to a POD
binding API.
# cat pod-binding-defintion.yaml
apiVersion: v1
kind: Binding
metadata:
name: myapp-pod
target:
apiVersion: v1
kind: Node
metadata:
name: node02
In the binding object specify a target node with a name of a node. And then send a post request to the pods binding API
with data set to binding object in JASON format.
so, you must convert YAM to JSON form.
# curl --header "Content-Type: application/json" --request POST --data '{"apiVersion": "v1", "kind": "Binding" ...}
http://#SERVER/api/v1/namespaces/default/pods/$PODNAME/binding/
No comments:
Post a Comment