K8s – Question9

Use context: kubectl config use-context k8s-c2-AC

Ssh into the controlplane node with ssh cluster2-controlplane1Temporarily stop the kube-scheduler, this means in a way that you can start it again afterwards.

Create a single Pod named manual-schedule of image httpd:2.4-alpine, confirm it’s created but not scheduled on any node.

Now you’re the scheduler and have all its power, manually schedule that Pod on node cluster2-controlplane1. Make sure it’s running.

Start the kube-scheduler again and confirm it’s running correctly by creating a second Pod named manual-schedule2 of image httpd:2.4-alpine and check if it’s running on cluster2-node1.

Manually Scheduling a Kubernetes Pod by Stopping the Scheduler

In this guide, we’ll explore how to manually schedule a Kubernetes Pod by temporarily stopping the Kubernetes scheduler. This exercise will give you a deeper understanding of how the scheduler works and how Pods are assigned to nodes.

Step 1: Stop the Scheduler

First, we need to identify the control plane node where the scheduler is running. Use the following command to list the nodes:

Next, SSH into the control plane node and check if the scheduler is running:

To stop the scheduler, move the scheduler’s manifest file out of the manifests directory:

Verify that the scheduler has stopped:

Step 2: Create a Pod

With the scheduler stopped, create a Pod using the following command:

Check that the Pod has no node assigned:

Step 3: Manually Schedule the Pod

To manually schedule the Pod, download its YAML definition and edit it to specify the node name:

Edit the 9.yaml file to include the node name:

Since you cannot use kubectl apply or kubectl edit for this, you’ll need to replace the Pod:

Check if the Pod is now running on the control plane node:

Step 4: Restart the Scheduler

After manually scheduling the Pod, restart the scheduler by moving the manifest file back to its original location:

Verify that the scheduler is running again:

Step 5: Create a Second Test Pod

To confirm that the scheduler is working normally again, create another Pod:

Check where both Pods are running:

Everything is back to normal, with the scheduler automatically assigning the second Pod to a node.

In this exercise, we manually scheduled a Kubernetes Pod by temporarily disabling the scheduler, showing how the scheduler assigns Pods to nodes and how you can intervene in this process if necessary.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *