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

配置Kubernetes联邦集群放置策略时遇kubectl get clusters无资源问题

Troubleshooting "No resource found" for kubectl get clusters in Kubernetes Federation

Let’s walk through the most likely issues that could be causing this error after you’ve set up your placement policies and configured the admission controller:

1. Verify your kubectl context is targeting the Federation API Server

It’s easy to accidentally stay connected to your local cluster’s context instead of the federation one. Here’s how to check and fix this:

  • List all available contexts:
    kubectl config get-contexts
    
  • Switch to your federation context (replace <federation-context> with your actual context name):
    kubectl config use-context <federation-context>
    

Even if you think you’re in the right context, double-check—this is the most common culprit for missing federation resources.

2. Ensure the Federation API Server’s admission controller changes took effect

You edited the apiserver deployment to add the SchedulingPolicy admission plugin, but we need to confirm those changes are working correctly:

  • First, check if the apiserver pod restarted successfully:
    kubectl -n federation-system get pods | grep apiserver
    
    Look for a Running status and a recent restart time (indicating the deployment picked up your changes).
  • Next, inspect the apiserver logs for errors related to the admission plugin or config file:
    kubectl -n federation-system logs <apiserver-pod-name>
    
    Search for keywords like SchedulingPolicy, admission-control-config-file, or error—you might find issues like an incorrect config file path, invalid YAML in the config, or a missing plugin dependency.
  • Confirm your --admission-control-config-file parameter points to the correct path where your scheduling-policy-admission.yaml is mounted in the pod. If you used a ConfigMap to mount the file, verify the ConfigMap exists and the mount path matches:
    kubectl -n federation-system get configmaps
    

3. Check if federated clusters are properly registered

If your clusters weren’t successfully registered with the Federation API Server, kubectl get clusters will return nothing. Try these steps:

  • Re-register your cluster (follow your federation setup steps for registration) to rule out registration failures.
  • Verify your kubectl version is compatible with the Federation API Server version—mismatched versions can lead to unrecognized resources. Run kubectl version to cross-check.

4. Confirm you’re querying the correct API group

Federation resource groups can vary slightly based on your federation version. Try querying with the full resource name to avoid ambiguity:

kubectl get clusters.federation.k8s.io

Or if you’re using an older federation version:

kubectl get clusters.core.federation.k8s.io

You can also list all supported resources to confirm the clusters resource exists in your current context:

kubectl api-resources | grep cluster

Start with the context check first—it’s the quickest fix. If that doesn’t work, move on to verifying the apiserver logs and cluster registration.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 03:38:53