Skip to main content
Welcome to this lesson from OpenShift 3 for the Absolute Beginners. In this article we cover how to scale applications in OpenShift — manually, from the CLI, and automatically (autoscaling). A DeploymentConfig (OpenShift) manages a ReplicationController; a Kubernetes Deployment manages a ReplicaSet. Both a ReplicationController and a ReplicaSet are responsible for maintaining multiple replicas of a Pod. Scaling an application means changing the number of replicas in the resource’s spec.replicas field. In demos so far we used a single replica. You can change the replica count by editing the object’s YAML, but the OpenShift web console provides a quick interactive way to scale up or down with one click. Traffic is automatically distributed to replicas by a Service (for cluster-internal traffic) or by the Router (for external traffic).
A slide titled "Scale Deployment" showing a diagram of a deployment/replication controller with stacked container/pod icons on the left. On the right is a web console screenshot for a "simple-webapp" deployment showing details and a circular indicator of 5 pods.
You can scale interactively in the web console for quick changes. Use the oc CLI for repeatable, scriptable operations and automation.

Common methods to scale

This section shows common ways to scale a DeploymentConfig or a Deployment in OpenShift: using the web console, using oc to scale/edit/patch, and enabling Horizontal Pod Autoscaling.

1) Scale using the oc CLI

Scale a DeploymentConfig directly:
If you use Kubernetes Deployments instead of DeploymentConfigs:
After scaling, verify new pods:
Example output:

2) Edit the YAML directly

Open the resource in your editor, change the spec.replicas value, save and exit. OpenShift will reconcile and create or terminate pods as needed. Edit a DeploymentConfig:
Edit a Deployment:
Alternatively, apply a modified YAML file:
Ensure spec.replicas in the file contains the desired count.

3) Patch the resource (quick one-liner)

Use oc patch to update replicas without opening an editor:

4) Enable autoscaling (Horizontal Pod Autoscaler)

OpenShift supports Horizontal Pod Autoscaling for DeploymentConfigs and Deployments. The oc autoscale command creates a HorizontalPodAutoscaler that scales based on metrics such as CPU utilization. Example:
This instructs the autoscaler to keep average CPU utilization near 80%, scaling between 2 and 10 replicas as needed. Check existing autoscalers:

Commands quick reference

When editing live resources, be mindful of production traffic. Changing replicas may disrupt session-affine workloads unless you use sticky sessions or an external session store.

Notes on traffic distribution

  • A Service that fronts your pods will automatically load-balance traffic across available replicas.
  • For externally exposed applications, the Router (OpenShift’s ingress point) distributes requests across Service endpoints (the pods).
  • Ensure readiness probes are configured so traffic is only sent to healthy pods.

Troubleshooting tips

  • If new pods remain in Pending, check node capacity with oc get nodes and pod events with oc describe pod <pod-name>.
  • If pods start but never become Ready, inspect logs and probe configurations:
    • oc logs <pod-name>
    • oc describe pod <pod-name>
  • For HPA issues, confirm metrics are available (metrics-server or Prometheus adapter as required).

Summary

  • Scaling changes the spec.replicas value of a DeploymentConfig or Deployment.
  • Web console scaling is convenient for ad-hoc changes; the oc CLI is best for automation.
  • Use oc scale, oc edit, or oc patch to adjust replicas from the CLI.
  • Use oc autoscale to add Horizontal Pod Autoscaling based on CPU (or other supported metrics).
  • Services and the Router handle traffic distribution across replicas automatically.

Watch Video