02 - Manual Scheduling
Q: Manually schedule the pod on "node01"
kubectl replace --force = kubectl delete + kubectl create
Method 1: kubectl replace
$ vim nginx.yaml
$ kubectl replace --force -f nginx.yaml
---
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
nodeName: node01
containers:
- image: nginx
name: nginx
Method 2: kubectl delete + kubectl create
$ kubectl delete po nginxTo list and know the names of available nodes on the cluster:
$ kubectl get nodesAdd the "nodeName" field under the spec section in the nginx.yaml file with "node01" as the value:
---
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
nodeName: node01
containers:
- image: nginx
name: nginxCreate a pod from the definition file.
$ kubectl create -f nginx.yamlTo check the status of a "nginx" pod and to know the node name:
$ kubectl get pods -o wideHow to determine why a pod is in a pending state
To determine why a pod is in a pending state, you can follow these steps:
1. Check Pod Status:
kubectl describe pod <pod-name>Output:
Node: <none>
這表示調度程序尚未完成在 Node 上的調度工作。
2. Look for Events:
In the output of the describe command, look for the "Events" section. This section often provides clues about why the pod is pending, such as insufficient resources, scheduling issues, or other constraints.
3. Check Scheduler:
kubectl get pods --namespace kube-systemLook for the scheduler pod in the "kube-system" namespace and check its status.
Based on the information provided, it seems that the scheduler might be missing, which would prevent the pod from being scheduled onto a node. If the scheduler is indeed missing, the correct answer to the question "Why is the POD in a pending state?" would be "No Scheduler Present".
留言
張貼留言