Search code examples
kuberneteskubectl

Getting all resources under a specific namespace doesn't show the deployed resource in k8s cluster


I deployed a simple ResourceQuota object in my k8s cluster under namespace foo:

apiVersion: v1
kind: ResourceQuota
metadata:
  name: my-resource-quota
  namespace: foo
spec:
  hard:
    pods: "2"
    requests.cpu: "1"
    requests.memory: 500Mi
    limits.cpu: "1"
    limits.memory: 500Mi

I can see the deployed quota under the namespace (quota is the shorthand name for resourcequota):

kubectl get quota -n foo
NAME                AGE   REQUEST                                                  LIMIT
my-resource-quota   5m   pods: 0/2, requests.cpu: 0/1, requests.memory: 0/500Mi   limits.cpu: 0/1, limits.memory: 0/500Mi

I double checked that the ResourceQuota is a namespaced object.

kubectl api-resources | grep quota
resourcequotas     quota        v1         true         ResourceQuota

The true in above output means it is a namespaced object.

At this moment, I have only deployed the quota object under namespace foo.

When I try to get all resources under namespace foo, I expect the output would also show me the quota object I deployed but the output shows "No resources found":

kubectl get all -n foo
No resources found in foo namespace.

It sounds like a contradictory behaviour of k8s API, why is that?


Solution

  • No, that is not true, kubectl get all is a false friend, it does not show everything in namespace, only pods, deployemnets, replicaset and services