# 来自服务器的错误（服务不可用）：服务器当前无法处理请求（获取 apiservices.apiregistration.k8s.io v1.metrics.k8s.io）

- **ID:** `kubernetes/apiservice-not-available`
- **领域:** kubernetes
- **类别:** runtime_error
- **错误码:** `503`
- **验证级别:** ai_generated
- **修复率:** 78%

## 根因

指标（或其他扩展）的 API 服务未响应，通常是因为相应的控制器（如 metrics-server）已关闭、配置错误或服务端点不可达。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Kubernetes 1.26 | active | — | — |
| Kubernetes 1.28 | active | — | — |
| metrics-server 0.6.3 | active | — | — |

## 解决方案

1. ```
   Check the status of the extension API server pod, e.g., for metrics-server: `kubectl get pods -n kube-system | grep metrics-server`. If down, check logs: `kubectl logs -n kube-system <metrics-server-pod>`.
   ```
2. ```
   Verify the service endpoint for the API service: `kubectl get endpoints -n kube-system <service-name>`. If no endpoints, the pod may not be listening on the correct port.
   ```
3. ```
   Delete and recreate the APIService resource to force re-registration: `kubectl delete apiservice v1.metrics.k8s.io && kubectl apply -f metrics-server-apiservice.yaml`.
   ```

## 无效尝试

- **** — Restarting the kube-apiserver pod does not fix the issue because the problem is with the extension API server, not the core API server. (80% 失败率)
- **** — Reapplying the APIService YAML without checking the underlying service status may lead to the same error if the service is still down. (60% 失败率)
