In this post I'll explain how deployments and replicasets work together.
When a deployment is created with the command below
k create deployment test --image=httpd --replicas=10
The deployment creates a replicaset and the replicaset manages the pods and makes sure the specified number of pods are running.
To see the number of pods running
k describe replicasets.apps test-6546ccdcf9
This is a partial result from the command above.
Replicas: 10 current / 10 desired
You can have many replicasets for a given deployment. One should not create a replicaset directly but use a deployment to do that. Here is what the kubernetes docs says about this.
https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/
A ReplicaSet ensures that a specified number of pod replicas are running at any given time. However, a Deployment is a higher-level concept that manages ReplicaSets and provides declarative updates to Pods along with a lot of other useful features. Therefore, we recommend using Deployments instead of directly using ReplicaSets, unless you require custom update orchestration or don't require updates at all.
You can accumulate multiple replicasets by doing updates. For example rolling updates and if you ever need to go back to a previous version you have the previous replicaset at your disposal.
To see or change the default number of replicasets kept, which is 10 run the command below.
k get deployments.apps test --output=yaml
spec:
replicas: 10
revisionHistoryLimit: 10
No comments:
Post a Comment