Pod Scheduling Troubleshooting using Minikube and Kind

Prakhar Gandhi
Google Cloud - Community
2 min readJun 12, 2024

Step 1: Install Minikube or kind

Step 2: Start a Kubernetes Cluster

Minikube:

minikube start

kind:

Create a Kubernetes cluster with multiple nodes using kind by defining a configuration file (e.g., kind-config.yaml) with multiple worker nodes:

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker

Then, create the cluster:

kind create cluster --config kind-config.yaml

Step 3: Verify Cluster Status

Ensure that your Kubernetes cluster is up and running:

kubectl cluster-info
kubectl get nodes

Step 4: Identify Resource Constraints

  • Check Resource Requests and Limits: Review the resource requests and limits specified in the pod manifests (cpu, memory). Ensure that the cluster nodes have sufficient capacity to accommodate these resource requirements.

Step 5: Review Affinity/Anti-Affinity Rules

  • Inspect Pod Affinity/Anti-Affinity: Check if there are any affinity or anti-affinity rules defined in the pod specifications (affinity, nodeSelector). Ensure these rules are correctly configured and not causing scheduling conflicts.

Step 6: Adjust Resource Allocation

  • Modify Pod Specifications: Adjust the resource requests (cpu, memory) in the pod YAML files if necessary to match the available resources in your cluster.

Step 7: Adjust Affinity/Anti-Affinity Rules

  • Modify Pod Specifications: Modify or remove affinity/anti-affinity rules in the pod YAML files to ensure pods can be scheduled without conflicts.

Step 8: Apply Changes and Deploy Pods

  • Apply Changes: Update the pod specifications with the adjusted resource requests and affinity rules.
kubectl apply -f <pod_spec.yaml>

Step 9: Monitor Pod Scheduling

  • Monitor Pods: Watch for pod scheduling events to verify that pods are now being scheduled successfully:
kubectl get pods --watch

Step 10: Troubleshoot and Iterate

  • Iterate as Needed: If pods still fail to schedule, review logs (kubectl describe pod <pod_name>) and events (kubectl get events) for any errors or additional constraints causing scheduling issues.
  • Adjust and Retry: Make further adjustments to resource requests/limits and affinity rules based on troubleshooting findings, and retry deploying pods.

By following these steps, you can set up a Kubernetes cluster using Minikube or kind, and troubleshoot pod scheduling issues related to resource constraints and affinity/anti-affinity rules effectively.

--

--

Prakhar Gandhi
Google Cloud - Community

Google Developer Educator for Jetpack Compose | Google Cloud Innovator | Geek | Cybersecurity | Code | Strategy