Retrieves a list of ReplicaSetSummary objects, similar to `kubectl get replicasets`
but including each replica set's deployment revision and container images.
A Deployment's replica sets are its revision history: every update to a Deployment
creates a new replica set carrying that revision's pod template, and older replica
sets are retained (scaled to zero). Listing them for one deployment therefore shows
when it last changed and what its image was at each revision - which is how you
answer "did something change recently?" without access to deployment tooling or
version control.
Results are grouped by namespace and owning deployment, and within each
deployment sorted by revision, oldest first. So when filtered to a single
deployment, the last entry is that deployment's current revision.
Replica sets with no revision (see `revision` below) sort *first*, ahead of
revision 1, rather than being dropped. They have no place in any deployment's
history, so they are listed before it rather than appended to it. In practice
they are only visible in an unfiltered listing: a replica set without a
revision has no owning deployment either, so passing `deployment` filters them
out, and the "last entry is the current revision" guarantee above is unaffected.
Parameters
----------
namespace : Optional[str], default=None
The specific namespace to list replica sets from. If None, lists from all namespaces.
deployment : Optional[str], default=None
If given, return only replica sets owned by this deployment. This is the common
case: one deployment's revision history.
Returns
-------
list of ReplicaSetSummary
A list of ReplicaSetSummary objects with the following fields:
name : str
Name of the replica set.
namespace : str
Namespace in which the replica set is defined.
owner_deployment : Optional[str]
Name of the Deployment that owns this replica set, or None if it is
standalone (not managed by a Deployment).
revision : Optional[int]
The deployment revision this replica set represents, taken from the
`deployment.kubernetes.io/revision` annotation. None when that
annotation is absent, which means no Deployment created this replica
set - only the Deployment controller writes it. A hand-written replica
set, or one created by another controller, therefore has no revision
(and no `owner_deployment`), and appears in neither `kubectl rollout
history` nor a `deployment`-filtered call here. Also None if the
annotation is present but not an integer.
desired_replicas : int
Replicas desired for this replica set. Old revisions are scaled to 0.
current_replicas : int
Replicas currently running.
ready_replicas : int
Replicas currently ready.
images : list[str]
Container images in this revision's pod template, in container order.
Comparing this across revisions shows what an upgrade changed.
age : datetime.timedelta
Age of the replica set (current time minus creation timestamp). For the
newest revision this is how long ago the deployment last changed.
Raises
------
K8sConfigError
If unable to initialize the K8S API.
K8sApiError
If the API call to list replica sets fails.