You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

kube-apiserver位置、安装配置及PV自动创建故障排查求助

Hey there! Let's work through your questions step by step to get your Kubernetes setup sorted out.

1. Where is kube-apiserver located?

The location depends on how you deployed Kubernetes:

  • If you used kubeadm for deployment, the kube-apiserver binary is typically installed at /usr/bin/kube-apiserver on control plane nodes. However, it usually runs as a static Pod managed by kubelet, so you can find its manifest file at /etc/kubernetes/manifests/kube-apiserver.yaml.
  • To locate the running kube-apiserver Pod, run this command:
    kubectl get pods -n kube-system | grep kube-apiserver
    
    You can access the Pod's shell to verify the binary path inside the container:
    kubectl exec -it <kube-apiserver-pod-name> -n kube-system -- /bin/sh
    # Inside the pod, check the path:
    which kube-apiserver
    
2. Fixing "kube-apiserver: command not found" & Configuring DefaultStorageClass

Why the command isn't found

If you're using kubeadm, kube-apiserver runs as a static Pod, so you don't execute it directly on the host. Running kube-apiserver from the host shell will fail unless you've added the binary path to your PATH (or call it with the full /usr/bin/kube-apiserver path). But modifying the apiserver's configuration requires editing its static Pod manifest instead of running the command manually.

How to enable the DefaultStorageClass admission plugin

  1. Edit the kube-apiserver static Pod manifest:
    sudo vi /etc/kubernetes/manifests/kube-apiserver.yaml
    
  2. Find the command section, look for the --enable-admission-plugins flag. If it exists, append DefaultStorageClass to the comma-separated list. If it doesn't exist, add the flag:
    command:
      - kube-apiserver
      - ... # other existing flags
      - --enable-admission-plugins=NodeRestriction,DefaultStorageClass
    
  3. Save the file. Kubelet will automatically detect the change and restart the kube-apiserver Pod.

Setting a default StorageClass

To make your example-nfs StorageClass the default (so PVCs without a storageClassName use it), run:

kubectl patch storageclass example-nfs -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
3. Troubleshooting PV not being created for your StatefulSet

Looking at your PVC logs and StorageClass details, the core issue is that the external provisioner example.com/nfs isn't creating a PV for your PVC. Here's how to diagnose:

  • First, confirm if the example.com/nfs provisioner is deployed and running:
    # Check for provisioner Pods (adjust namespace if you deployed it elsewhere)
    kubectl get pods -n kube-system | grep nfs-provisioner
    
    If no such Pod exists, you need to deploy the NFS external provisioner first. This usually involves deploying a Deployment/StatefulSet that runs the provisioner container, along with appropriate RBAC permissions to create PVs.
  • If the provisioner Pod exists, check its logs for errors:
    kubectl logs -n kube-system <nfs-provisioner-pod-name>
    
    Common issues here include:
    • The provisioner can't reach your NFS server
    • Incorrect NFS server path or permissions
    • Missing RBAC permissions for the provisioner to create PVs
  • Your PVC is explicitly using example-nfs as the StorageClass, so the DefaultStorageClass plugin won't affect this specific PVC—it only helps when no storageClassName is specified.
4. How to check logs for storage provisioning issues

Here are key logs to inspect:

  • PersistentVolume Controller logs: This controller manages PV/PVC binding and interacts with provisioners. It's part of the kube-controller-manager Pod:
    # First get the kube-controller-manager Pod name
    kubectl get pods -n kube-system | grep kube-controller-manager
    # Then filter logs for persistentvolume-controller
    kubectl logs -n kube-system <kube-controller-manager-pod-name> | grep persistentvolume-controller
    
  • External provisioner logs: As mentioned earlier, check the logs of your example.com/nfs provisioner Pod to see why it's not creating PVs.
  • PVC event history: You already ran kubectl describe pvc nfs, but rechecking events can show new updates. Use this command to watch events in real-time:
    kubectl events -w --field-selector involvedObject.name=nfs,involvedObject.kind=PersistentVolumeClaim
    
  • StorageClass logs: While your StorageClass shows no events, you can still verify its configuration matches the provisioner's expected settings.

内容的提问来源于stack exchange,提问作者raj_arni

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 10:04:30