Updating Multiple Objects

In this lesson, we will learn how to update multiple deployments at a time.

The Use of Selector Labels

Even though most of the time we send requests to specific objects, almost everything is happening using selector labels. When we updated the Deployments, they looked for matching selectors to choose which ReplicaSets to create and scale. They, in turn, created or terminated Pods also using the matching selectors.

Almost everything in Kubernetes is operated using label selectors. It’s just that sometimes that is obscured from us.

We do not have to update an object only by specifying its name or the YAML file where its definition resides. We can also use labels to decide which object should be updated. That opens some interesting possibilities since the selectors might match multiple objects.

Defining the Deployment

Imagine that we are running several Deployments with Mongo databases and that the time has come to update them all to a newer release. Before we explore how we could do that, we’ll create another Deployment so that we have at least two with the database Pods.

Let us first take a look at the definition.

Get hands-on with 1200+ tech skills courses.