Common Issues of Kubectl
Error report of kubectl top command
There are generally two possibilities for this situation:
- The metrics-server Pod under kube-system is not working properly, which can be checked by
kubectl get pods -n kube-system
- The
metrics.k8s.io
API address was redirected erroneously. You can executekubectl get apiservice v1beta1.metrics.k8s.io
to view the service name redirected to, and confirm whether the service is currently available and whether it has exposed thev1beta1.metrics.k8s.io
interface. The default redirected address iskube-system/metrics-server
The second situation usually occurs when prometheus is deployed and the interface provided by prometheus does not support v1beta1.metrics.k8s.io. If there’s no need to customize HPA indicators, this redirect operation is not necessary. If it’s the second case, you can follow the steps below.
- Confirm that the prometheus service in the configuration is available, and customize HPA indicators as needed [Customize HPA Indicators](/docs/uk8s/autoscaling/autoscale_on_custom_metrics#Enable custommetricsk8sio service)
- Redeploy and execute the following yaml file to rollback to the general metrics server, Grafana, etc do not depend on this api.
- Note that if you have used custom HPA indicators before and are in an online environment, it is recommended that you only confirm that prometheus service is available. Rolling back to the general metrics server may cause your previous custom HPA indicators to fail, please operate carefully.
apiVersion: apiregistration.k8s.io/v1beta1
kind: APIService
metadata:
name: v1beta1.metrics.k8s.io
spec:
service:
name: metrics-server
namespace: kube-system
group: metrics.k8s.io
version: v1beta1
insecureSkipTLSVerify: true
groupPriorityMinimum: 100
versionPriority: 100