Solution Manual Horizontal Scaling Imperative scaling Declarative scaling While using the scale command is trivially simple and good for quick reactions to emergencies, it does not preserve this configuration outside the cluster. Typically, all Kubernetes applications would have their resource definitions stored in a source con‐ trol system that also includes the number of replicas. Recreating the ReplicaSet from its original definition would change the number of replicas back to its previous num‐ After such a change, the ReplicaSet could either create additional Pods to scale up, or if there are more Pods than desired, delete them to scale down. A controller such as ReplicaSet is responsible for making sure a specific number of Pod instances are always up and running. Thus, scaling a Pod is as trivially simple as changing the number of desired replicas. Given a Deployment named  random- generator , scaling it to four instances can be done in one command, as shown in Example 24-1. The manual scaling approach, as the name suggests, is based on a human operator issuing commands to Kubernetes. This approach can be used in the absence of autoscaling, or for gradual discovery and tuning of the optimal configuration of an application matching the slow-changing load over long periods. An advantage of the manual approach is that it also allows anticipatory rather than reactive-only changes: knowing the seasonality and the expected application load, you can scale it out in advance, rather than reacting to already increased load through autoscaling, for example. We can perform manual scaling in two styles. There are two main approaches to scaling any application: horizontal and vertical. Horizontally  in the Kubernetes world equates to creating more replicas of a Pod.  Ver‐ tically  scaling implies giving more resources to running containers managed by Pods. While it may seem straightforward on paper, creating an application configuration for autoscaling on a shared cloud platform without affecting other services and the cluster itself requires significant trial and error. As always, Kubernetes provides a variety of features and techniques to find the best setup for our applications, and we explore them briefly here. Example 24-1. Scaling a Deployment’s replicas on the command line kubectl scale random-generator --replicas=4 204  |  Chapter 24: Elastic Scale