Viewing, finding resources
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector
flag.
1kubectl get pods # List all pods in the namespace
2kubectl get nodes # List all nodes in the cluster
3kubectl get deployments # List all deployments in the namespace
4kubectl get configmaps # List all configmaps in the namespace
5kubectl get services # List all services in the namespace
6kubectl get secrets # List all secrets in the namespace
7kubectl get replicasets # List all replicasets in the namespace
8kubectl get daemonsets # List all daemonsets in the namespace
9kubectl get statefulsets # List all statefulsets in the namespace
10kubectl get endpoints # List all endpoints in the namespace
11kubectl get ingress # List all ingress in the namespace
12kubectl get serviceaccounts # List all serviceaccounts in the namespace
13kubectl get roles # List all roles in the namespace
14kubectl get rolebindings # List all rolebindings in the namespace
15kubectl get clusterroles # List all clusterroles in the namespace
16kubectl get clusterrolebindings # List all clusterrolebindings in the namespace
You can sepecify above commands with -n
or --namespace
namespace parameter
ex. kubectl get secrets -n example
Also you can list all resources under all namespaces at ones using -A
or --all-namespaces
parameter
ex. kubectl get deployments -A
1kubectl get pods -o wide # List all pods in the current namespace, with more details
2kubectl get deployment my-dep # List a particular deployment
3
4kubectl get pod nginx -o yaml # Get nginx pod's YAML
5
6# List all replication controllers and services together
7kubectl get rc,services
8
9# Get ExternalIPs of all nodes
10kubectl get nodes -o jsonpath='{.items[*].status.addresses[?(@.type=="ExternalIP")].address}'
11
12# Check which nodes are ready
13JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}' \
14&& kubectl get nodes -o jsonpath="$JSONPATH" | grep "Ready=True"