You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cmd="/snap/microk8s/current/kubectl --kubeconfig /var/snap/microk8s/current/credentials/client.config top pod -n ${JUJU_MODEL_NAME} --no-headers".split()
This is way too brittle. Calling various microk8s commands differs between strictly confined and not. The amount of scraping needed to actually pull this in "properly" is enormous, and it's honestly a PITA to get any of these out without something running inside the cluster, but there is a middle ground between "literally call kubectl top pod" and run in k8s.
That middle ground is: kubectl get --raw /apis/metrics.k8s.io/v1beta1 | jq
You can drill into nodes or pods.
For kubectl get --raw "/apis/metrics.k8s.io/v1beta1/pods" | jq, you'll get a list of all of the objects. Including metadata, like the namespace, which can be used to filter.
sed-i
changed the title
This is way too brittle. Calling various microk8s commands differs between strictly confined and not. The amount of scraping needed to actually pull this in "properly" is [enormous](https://github.com/prometheus-community/helm-charts/blob/main/charts/prometheus/values.yaml#L635), and it's honestly a PITA to get any of these out without something running inside the cluster, but there is a middle ground between "literally call kubectl top pod" and run in k8s.
Fix how kubectl top pod is called
Apr 18, 2023
This is way too brittle. Calling various
microk8s
commands differs between strictly confined and not. The amount of scraping needed to actually pull this in "properly" is enormous, and it's honestly a PITA to get any of these out without something running inside the cluster, but there is a middle ground between "literally callkubectl top pod
" and run in k8s.That middle ground is:
kubectl get --raw /apis/metrics.k8s.io/v1beta1 | jq
You can drill into
nodes
orpods
.For
kubectl get --raw "/apis/metrics.k8s.io/v1beta1/pods" | jq
, you'll get a list of all of the objects. Including metadata, like the namespace, which can be used to filter.All of the certs are in
/snap/microk8s/current/certs-beta/
. You can pretty much yank all of these in pure Python (no subprocess) with something like:curl $KUBE_API/apis/apps/v1/deployments \ --cacert /snap/microk8s/current/certs-beta/ca.crt \ --cert /snap/microk8s/current/certs-beta/client.crt \ --key /snap/microk8s/current/certs-beta/client.key
Yank the certs into the exporter on startup, and use
requests
orurllib
or whatever you want to read it all and transformOriginally posted by @rbarry82 in #65 (comment)
The text was updated successfully, but these errors were encountered: