Using cURL from inside Kubernetes Pod for API Metric Server

4/9/2020

I'm having issues with curling from a Java Spring-boot application to retrieve data from the metrics API.

I'm using a custom service-account that has access to everything and the command executes properly using kube exec. In this case i'm using the token that I get from the /var/run/secrets/kubernetes.io/serviceaccount/token.

kube exec -it of the curl command

Here you can see that a proper output is given but when the same curl command is called through java code this is the output.

kubectl logs -podname-

In the next image you can see the Java code the result token here is again pulled from the directory and I can verify in the output that the command is exactly the same as the one ran during kubectl exec.

enter image description here

I've been banging my head against this for quite some time and I'm wondering what is going wrong.

EDIT: A way to fix this but probably not very best practice is by executing this command in your cluster kubectl create clusterrolebinding the-boss --user system:anonymous --clusterrole cluster-admin

-- Harvär Budsen
api
curl
kubernetes
kubernetes-apiserver
metrics

0 Answers