I am looking for a way to get resource quotas for the namespace using client-go, similar to kubectl describe ns my-namespace-name
.
I have tried ns, err := k8client.CoreV1().Namespaces().Get("my-namespace-name", metav1.GetOptions{})
but it does not give quota info.
Also tried ns, err := k8client.CoreV1().ResourceQuotas("my-namespace-name").Get("name", metav1.GetOptions{})
but I can not figure out what to put as name
parameter in .Get(). Tried namespace name, tried several resource types from https://kubernetes.io/docs/reference/kubectl/overview/#resource-types but no luck with errors like resourcequotas "namespaces" not found
or resourcequotas "limits.cpu" not found
Tried ns, err := k8client.CoreV1().ResourceQuotas("my-namespace-name").List(metav1.ListOptions{})
as well but it returned no result.
Any ideas on how to get it will be much appreciated!
Ok, after some debugging and going through kubernetes and kubectl code, the way to get it is: ns, err := k8client.CoreV1().ResourceQuotas("my-namespace-name").List(metav1.ListOptions{})
Not sure why it did not work for me first time I have tried, might have made a typo in namespace name.