ReplicaSet

2 min read

Read a Deployment’s ReplicaSets, passed as a list: how many, their names, and which are older than the Deployment’s current revision; and any object’s controller, from its ownerReferences.

Reference

FunctionDescription
deploymentReplicaSetCountReturns the number of ReplicaSets, including scaled-to-zero ones a Deployment keeps for rollback.
deploymentReplicaSetsReturns the ReplicaSets’ names.
oldDeploymentReplicaSetsReturns the names of the deployment’s ReplicaSets that are not its current revision: those whose deployment.kubernetes.io/revision annotation differs from the Deployment’s.
replicaSetOwnerKindReturns the kind of the object’s controller; for a ReplicaSet, typically “Deployment”.
replicaSetOwnerNameReturns the name of the object’s controller (the ownerReference with controller: true); for a ReplicaSet, its Deployment.

Functions

deploymentReplicaSetCount

deploymentReplicaSetCount returns the number of ReplicaSets, including scaled-to-zero ones a Deployment keeps for rollback.

{{ deploymentReplicaSetCount .replicaSets }}  → 2

deploymentReplicaSets

deploymentReplicaSets returns the ReplicaSets’ names.

{{ deploymentReplicaSets .replicaSets }}  → [web-6d4f web-5c8b]

oldDeploymentReplicaSets

oldDeploymentReplicaSets returns the names of the deployment’s ReplicaSets that are not its current revision: those whose deployment.kubernetes.io/revision annotation differs from the Deployment’s. Empty until the Deployment has a revision.

{{ oldDeploymentReplicaSets .deployment .replicaSets }}  → [web-5c8b]

replicaSetOwnerKind

replicaSetOwnerKind returns the kind of the object’s controller; for a ReplicaSet, typically “Deployment”.

{{ replicaSetOwnerKind .replicaset }}  → "Deployment"

replicaSetOwnerName

replicaSetOwnerName returns the name of the object’s controller (the ownerReference with controller: true); for a ReplicaSet, its Deployment.

{{ replicaSetOwnerName .replicaset }}  → "web"