Run a pod without scheduler in Kubernetes

Viewed 2908

I searched the documentation but I am unable to find out if I can run a pod in Kubernetes without Scheduler. If anyone can help with any pointers it would be helpful

Update: I can attach a label to node and let pod stick to that label but that would involve going through the scheduler. Is there any method without daemonset and does not use scheduler.

5 Answers

The scheduler just sets the spec.nodeName field on the pod. You can set that to a node name yourself if you know which node you want to run your pod, though you are then responsible for ensuring the node has sufficient resources to run the pod (enough memory, free host ports, etc… all things the scheduler is normally responsible for checking before it assigns a pod to a node)

You want static pods

Static pods are managed directly by kubelet daemon on a specific node, without API server observing it. It does not have associated any replication controller, kubelet daemon itself watches it and restarts it when it crashes.

You can simply add a nodeName attribute to the pod definition which by they normally field out by the scheduler therefor it's not a mandatory field.

apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
  -  image: nginx
     name: nginx
  nodeName: node01

if the pod has been created and in pending state you have to recreate it with the new field, edit is not permitted with the nodeName att.

All the answers given here would require a scheduler to run.

I think what you want to do is create the manifest file of the pod and put it in the default manifest directory of the node in question.

Default directory is /etc/kubernetes/manifests/

The pod will automatically be created and if you wish to delete it, just delete the manifest file.

You can simply add a nodeName attribute to the pod definition

apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  nodeName: controlplane
  containers:
  -  image: nginx
     name: nginx

Now important point - check the node listed by using below command, and then assign to one of them:

kubectl get nodes
Related