nolar / kopf

A Python framework to write Kubernetes operators in just a few lines of code

Home Page:https://kopf.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to avoid Errors accessing metrics API and CRDs

tmmorin opened this issue · comments

Long story short

I'm writing a small controller with no CRD associated that only reacts to changes on Nodes and Pods.

For reasons unrelated to this issue (which I'm solving separately) I see this kind of errors on startup:

[2024-04-15 13:25:28,246] kopf._core.reactor.o [ERROR   ] Request attempt #1/9 failed; will retry: GET https://100.73.0.1:443/apis/metrics.k8s.io/v1beta1 -> APIServerError(None, None)                                                           
[2024-04-15 13:25:29,252] kopf._core.reactor.o [ERROR   ] Request attempt #2/9 failed; will retry: GET https://100.73.0.1:443/apis/metrics.k8s.io/v1beta1 -> APIServerError(None, None)  

And, similarly:

[2024-04-15 13:26:33,105] kopf._core.reactor.o [ERROR   ] Request attempt #1/9 failed; will retry: GET https://100.73.0.1:443/apis/metallb.io/v1beta1 -> ClientConnectorError(ConnectionKey(host='100.73.0.1', port=443, is_ssl=True, ssl=True, pr
oxy=None, proxy_auth=None, proxy_headers_hash=-7154211259067671165), OSError(113, "Connect call failed ('100.73.0.1', 443)"))                                                                                                                                                                                     
[2024-04-15 13:26:33,106] kopf._core.reactor.o [ERROR   ] Request attempt #1/9 failed; will retry: GET https://100.73.0.1:443/apis/ipam.cluster.x-k8s.io/v1alpha1 -> ClientConnectorError(ConnectionKey(host='100.73.0.1', port=443, is_ssl=True, 
ssl=True, proxy=None, proxy_auth=None, proxy_headers_hash=-7154211259067671165), OSError(113, "Connect call failed ('100.73.0.1', 443)"))    

At some point Kopf framework abandons...

My question is the following: **given that my controller does not do anything with the metrics API or with CRDs, could I configure Kopf so that it would not try to fetch all of this ?

Kopf version

1.37.2

Kubernetes version

1.28.8

Python version

3.12

Code

No response

Logs

No response

Additional information

No response

You could just deploy the metrics server on your cluster to see if that solves your problem. It's lightweight. https://github.com/kubernetes-sigs/metrics-server