Skip to main content
Welcome to this demo on scaling applications in OpenShift for beginners. In this lesson we deploy a simple Python web application, scale it up and down, and observe how an OpenShift Route and Service distribute traffic across application instances. This demo uses a small, colorful Flask app that selects a background color on startup (or via an environment variable). The repository for the app is named Simple Web App Color.
A GitLab project page for "simple-webapp-color" showing project details, repository controls (star, fork, HTTP URL) and an orange banner about adding an SSH key. The left sidebar displays navigation items like Overview, Details, Repository, Issues and CI/CD.
Overview of the demo workflow
  • Create a new project (namespace) in OpenShift.
  • Add the application by pointing the console to the Git repository.
  • Build and deploy the image (watch the push progress).
  • Access the app via the Route URL.
  • Scale replicas from the web console and observe traffic distribution.
  • Optionally change the router balancing annotations to alter session affinity.
Application code (Flask) The app renders a simple page showing the container hostname and a background color. The color is chosen randomly on first start unless APP_COLOR is set.
What happens when you deploy
  • The OpenShift Build will create an image and push it to the internal registry. During the push you might see progress lines like:
  • OpenShift creates a Deployment (or DeploymentConfig), Pods, a Service that selects those Pods, and a Route that exposes the Service externally.
  • The Route provides the external URL you use to access the app. Each request to that Route will be forwarded to one of the Service endpoints (pods) according to the router’s load-balancing behavior.
Scaling from the OpenShift console
  • In the web console you can increase or decrease the replica count using the up/down arrows on the application’s Deployment card.
  • Scaling updates the Deployment’s replica count and the OpenShift controller creates or removes pods to match the desired replicas.
  • Because the Service selector targets the Deployment’s pods, newly created pods automatically become endpoints and receive traffic.
Why you see different colors
  • Each pod may choose a different color at startup, so multiple replicas can show different background colors.
  • When you scale to 2+ replicas and access the Route URL from different browser sessions (or incognito windows), you will likely hit different pods and see different colors.
  • If you refresh the same browser tab repeatedly and keep getting the same pod, that indicates session affinity on the router (sticky sessions) or a load-balancing algorithm that consistently maps your client to the same backend.
OpenShift router balancing and session affinity The router’s behavior (balance algorithm, cookie usage, session affinity) is controlled via Route annotations. To change how traffic is balanced, edit the Route YAML and add annotations such as:
Common router-related annotations After you save the Route with balance: "roundrobin" and disable_cookies: "true", subsequent requests from the same browser tab will be more evenly distributed across pods instead of being pinned to one. Scaling via CLI (optional) You can also scale from the command line using oc. Example:
  • Scale to 3 replicas: oc scale deployment/simple-webapp-color --replicas=3 -n your-project
  • Check pods and endpoints: oc get pods -n your-project oc get endpoints -n your-project
Best practice for session state
If you need session affinity for application-level sessions, consider using a dedicated session store (for example, Redis, a database, or another central store) instead of relying on router stickiness. Router annotations for sticky sessions can help but are not a replacement for centralized session management.
Quick reference: OpenShift resources involved Links and references That’s it — a short demo showing how to deploy, scale, and control route behavior in OpenShift.

Watch Video