Marc
Marc

Reputation: 14269

How to change Kubernetes metrics-server port?

The default Kubernetes (K3S) installation (rather rudely) occupies port 443 with the metrics-server. I am able to patch the service to change the port but then kubectl does not know how to query metrics. Where do I change the port for the kubectl client? Port 443 is not not in ~./kube/config (only 6443 - the api port).

$ kubectl get --raw "/apis/metrics.k8s.io/v1beta1/nodes"
{"kind":"NodeMetricsList","apiVersion":"metrics.k8s.io/v1beta1",...
$ kubectl patch service metrics-server -n kube-system --type='json' --patch='[{"op": "replace", "path": "/spec/ports/0/port", "value":7443}]'
service/metrics-server patched
$ kubectl get --raw "/apis/metrics.k8s.io/v1beta1/nodes"
Error from server (ServiceUnavailable): the server is currently unable to handle the request

Upvotes: 0

Views: 2834

Answers (1)

gohm'c
gohm'c

Reputation: 15480

metrics-server has registered 443 with api-server during installation. Easiest way is disable the bundled metrics-server and re-install with the service port set to 7443 here, so the call out would reach the right port. If you are using the manifest, amend the port number here.

Upvotes: 1

Related Questions