Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clean up "Replica Sets" when updating deployments?

Tags:

kubernetes

Every time a deployment gets updated, a new replica set is added to a long list. Should the old rs be cleaned?

like image 589
yuval Avatar asked May 16 '16 13:05

yuval


People also ask

What is the relationship between deployments and replica sets?

Deployment is an object which can own ReplicaSets and update them and their Pods via declarative, server-side rolling updates. While ReplicaSets can be used independently, today they're mainly used by Deployments as a mechanism to orchestrate Pod creation, deletion and updates.

How do you update a replica set?

Try to update your ReplicaSet through the command kubectl edit rs $REPLICASET_NAME ; you will access this resource via the default editor with a YAML configuration file: // demonstrate to change the number of Pod replicas.

Can a deployment have multiple replica sets?

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 .


1 Answers

Removing old replicasets is part of the Deployment object, but it is optional. You can set .spec.revisionHistoryLimit to tell the Deployment how many old replicasets to keep around.

Here is a YAML example:

apiVersion: apps/v1 kind: Deployment # ... spec:   # ...   revisionHistoryLimit: 0 # Default to 10 if not specified   # ... 
like image 140
rwehner Avatar answered Sep 16 '22 18:09

rwehner