148422597X Kubernetes Management Design Patterns [Vohra 2017-01-29] {E559F6BB}

marco.cirilli
from marco.cirilli More from this publisher
19.06.2021 Views

Chapter 8 ■ Using Rolling UpdatesPerform a rolling update of the mysql-v1 RC to a new RC called postgresql using a new Docker image,postgres:kubectl rolling-update mysql–v1 postgresql --image=postgresThe rolling update is started as shown in Figure 8-16.Figure 8-16. Starting a rolling updateWhile the rolling update is running, terminate the update with ^C as shown in Figure 8-17.Figure 8-17. Terminating a rolling updateTo resume the rolling update, run the same command again:kubectl rolling-update mysql–v1 postgresql --image=postgresAs the output in Figure 8-18 indicates, the existing update is found and resumed.Figure 8-18. Resuming a rolling update183

Chapter 8 ■ Using Rolling UpdatesThe rolling update is completed using an existing update as shown in Figure 8-19. Next, list the new RCand pods.Figure 8-19. Rolling update using existing updateRolling Back an UpdateA rollback of a rolling update can be performed if required. As an example, a rolling update to an RC calledpostgresql is started using a new container image mysql:kubectl rolling-update postgresql mysql --image=mysqlNow suppose that while the rolling update is still in progress, we realize the update should not havebeen started, or was started in error, or needs to be started with different parameters. Using ^C, terminatethe update. Then run the following command to roll back the update:kubectl rolling-update postgresql mysql –rollbackWhen the rolling update was terminated, the postgresql RC had already scaled down to one pod andthe mysql RC had already scaled up to two pods. When the rollback is performed, the existing controllerpostgresql is scaled back up from one to three pods and the mysql RC is scaled down from two to zero pods,as shown in Figure 8-20.184

Chapter 8 ■ Using Rolling Updates

The rolling update is completed using an existing update as shown in Figure 8-19. Next, list the new RC

and pods.

Figure 8-19. Rolling update using existing update

Rolling Back an Update

A rollback of a rolling update can be performed if required. As an example, a rolling update to an RC called

postgresql is started using a new container image mysql:

kubectl rolling-update postgresql mysql --image=mysql

Now suppose that while the rolling update is still in progress, we realize the update should not have

been started, or was started in error, or needs to be started with different parameters. Using ^C, terminate

the update. Then run the following command to roll back the update:

kubectl rolling-update postgresql mysql –rollback

When the rolling update was terminated, the postgresql RC had already scaled down to one pod and

the mysql RC had already scaled up to two pods. When the rollback is performed, the existing controller

postgresql is scaled back up from one to three pods and the mysql RC is scaled down from two to zero pods,

as shown in Figure 8-20.

184

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!