Applications deployed using a controller like a Deployment or statefulSet can be scaled up or down by modifying the number of replicas.
replicas key value in the controller’s spec will trigger an update to the application’s current replicaSet that increases (or reduces) the number of pods that run the application. This is done imperatively using
$ kubectl scale deploy redis-prod --replicas=3 deployment.apps/redis-prod scaled $
Or declaratively by making changes to the controller’s spec’s YAML and applying it to the cluster:
$ nano redis-prod.yaml apiVersion: apps/v1 kind: Deployment metadata: labels: app: redis-prod name: redis-prod spec: replicas: 5 selector: matchLabels: app: redis-prod template: metadata: labels: app: redis-prod spec: containers: - image: redis:4.0 name: redis $ kubectl apply -f redis-prod.yaml deployment.apps/redis-prod configured $
Learn more about scaling your applications using controllers like deployments.