  def _ReplicaSet(self) -> 'K8sReplicaSet':
    """Gets the matching ReplicaSet of this deployment.

    Returns:
      K8sReplicaSet: The matching ReplicaSet of this deployment.

    Raises:
      errors.ResourceNotFoundError: If the matching ReplicaSet was not found.
    """

    # The matching ReplicaSet will have labels corresponding to this
    # deployment's matchLabels.
    replica_sets_selector = selector.K8sSelector.FromLabelsDict(
        self.MatchLabels())

    replica_sets = self._Api(client.AppsV1Api).list_namespaced_replica_set(
        self.namespace, **replica_sets_selector.ToKeywords()).items

    this_template_spec = self.Read().spec.template
    for replica_set in replica_sets:
      rs_template_spec = replica_set.spec.template
      # Delete the hash appended to the labels of this replicaset, so that
      # the following comparison does not factor in the hash label
      if 'pod-template-hash' in rs_template_spec.metadata.labels:
        del rs_template_spec.metadata.labels['pod-template-hash']
        if rs_template_spec == this_template_spec:
          return K8sReplicaSet(
              self._api_client,
              replica_set.metadata.name,
              replica_set.metadata.namespace,
          )

    raise errors.ResourceNotFoundError(
        'Matching ReplicaSet for deployment {0:s} not found.'.format(self.name),
        __name__)
Gets the matching ReplicaSet of this deployment.

Returns:
K8sReplicaSet: The matching ReplicaSet of this deployment.

Raises:
errors.ResourceNotFoundError: If the matching ReplicaSet was not found.
libcloudforensics/providers/kubernetes/workloads.py