Use an alias to list resources in Kubernetes
by Alex Arica

In Kubernetes, the command "kubectl get all" does not return all available resources. It returns a fix list of resources, as follows:

pods
services
daemonset
replicasets
deployments
jobs
                    

Since "get all" is limited by design, if we want to view a custom list of resources, one of the possible solution is to create a bash alias in the file "~/.bashrc".

Creation of a bash alias

Open "~/.bashrc":

vi ~/.bashrc
                    

And in it an alias "kubectl-all", as follows:

alias kubectl-all='kubectl get pod,job,deployment,secret,svc,ingress,clusterissuer,issuer,certificate,certificaterequest,order,challenge'
                    

Save it and then run:

source ~/.bashrc
                    

From now, if we run the command "kubectl-all", Kubernetes will list the resources as defined in the alias. We can combine it to a namespace too. In the example below, we list all resources in the namespace "kube-system":

kubectl-all -n kube-system
                    

All available resources

To help us deciding which resources we would like to list, we can use a command provided by Kubernetes which lists all available resources' names:

kubectl api-resources -o name