K8s – Question2

Use context: kubectl config use-context k8s-c1-H

Create a single Pod of image httpd:2.4.41-alpine in Namespace default. The Pod should be named pod1 and the container should be named pod1-container. This Pod should only be scheduled on controlplane nodes. Do not add new labels to any nodes.

How to Schedule a Pod on Control Plane Nodes in Kubernetes

In Kubernetes, there are scenarios where you might want to schedule a Pod to run exclusively on control plane nodes. This guide will show you how to create a Pod that runs only on control plane nodes without adding any new labels to the nodes.

Step 1: Identify Control Plane Nodes and Their Taints

First, you need to identify the control plane node(s) in your cluster and check for any taints that might prevent Pods from being scheduled on them. Use the following commands:

Step 2: Create a Pod Template

Now that you have identified the control plane node, create a Pod template. Generate a basic Pod configuration with the following command:

Step 3: Modify the Pod Configuration

Edit the pod1.yaml file to ensure the Pod is only scheduled on control plane nodes. Open the file in a text editor and update it as follows:

This configuration adds tolerations and a node selector to ensure the Pod is scheduled only on control plane nodes.

Step 4: Create the Pod

Once the configuration is set, create the Pod using the following command:

Step 5: Verify the Pod Scheduling

Finally, verify that the Pod is running on the control plane node:

You should see that the NODE column indicates that the Pod is running on the specified control plane node.

By following these steps, you can ensure that your Pod is scheduled only on control plane nodes in your Kubernetes cluster. This method provides better control over where your workloads are running.

Leave a Reply

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