'Kubernetes - can a Deployment have multiple ReplicaSets?

Just finished reading Nigel Poulton's The Kubernetes Book. I'm left with the question of whether or not a Deployment can specify multiple ReplicaSets.

When I think Deployment, I think of it in the traditional sense of an entire application being deployed. Or is there meant to be a Deployment for each microservice?

apiVersion: apps/v1beta2
kind: Deployment
metadata: 
  name: hello-deploy
spec:
  replicas: 10
  selector:
    matchLabels:
      app: hello-world
  minReadySeconds: 10
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1
      maxSurge: 1
  template:
    metadata:
      labels:
        app: hello-world
    spec:
      containers:
      - name: hello-pod
        image: nigelpoulton/k8sbook : latest
        ports:
        - containerPort: 8080


Solution 1:[1]

It is meant to be a deployment of each microservice.

You can also manage the quantity of "deployed services" of each microservices type. So for instance, if you want to deploy Service A (Docker image with an Java service) 5 times, you have a deployment resulting 5 pods. Each pod contains the image of Service A.

If you deploy a new version of this Service A (Docker image with an Java service), Kubernetes is able to do a rolling update and manage the shut down of the old Java service type (the existing pods) and creates 5 new pods with the new Java Service A.2 (a new docker image).

Thus your whole microservices application/infrastructure is build upon multiple deployments. Each generating Kubernetes pods, which are published by Kubernetes services.

Solution 2:[2]

A deployment contains a single pod template, and generates one replicaset per revision

Solution 3:[3]

The replica sets can be multiple up to a limit of 10 based on the number of updates that have been done using deployment. But only one replicaSet (the latest one) should be showing the number of pods; all other older sets should be showing 0.

We can set revisionHistoryLimit to specify how many old replicaSets we want to retain: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#clean-up-policy

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lennart Blom
Solution 2 Jordan Liggitt
Solution 3 Jeremy Caney