Chapter 3. Learning to Use the Kubernetes Client
This chapter gathers recipes around the basic usage of the Kubernetes CLI, kubectl
. See Chapter 1 for how to install the CLI tool; for advanced use cases, see Chapter 7, where we show how to use the Kubernetes API.
3.1 Listing Resources
Problem
You want to list Kubernetes resources of a certain kind.
Solution
Use the get
verb of kubectl
along with the resource type. To list all pods, do this:
$ kubectl get pods
To list all services and deployments (note that there is no space after the comma), do this:
$ kubectl get services,deployments
To list a specific deployment, do this:
$ kubectl get deployment <deployment-name>
To list all resources, do this:
$ kubectl get all
Note that kubectl get
is a very basic but extremely useful command to get a quick overview what is going on in the cluster—it’s essentially the equivalent to ps
on Unix.
Discussion
We strongly ...
Get Kubernetes Cookbook, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.