Specifying Pod Replicas in Configuration Workloads

The number of pod replicas for a specific deployment or deployment configuration can be increased or decreased to meet your needs. Despite the ReplicaSet and ReplicationController resources, the number of replicas needed for an application is typically defined in a deployment or deployment configuration resource.

A replica set or replication controller (managed by a deployment or a deployment configuration) guarantees that the specified number of replicas of a pod are running at all times. The replica set or replication controller can add or remove pods as necessary to conform to the desired replica count.

Both deployments and deployment configurations contain:

  • The desired number of replicas
  • A selector for identifying managed pods
  • A pod definition, or template, for creating a replicated pod (including labels to apply to the pod)

The following deployment resource (created using the oc create deployment command) displays the following items:

apiVersion: apps/v1
kind: Deployment
...output omitted...
    replicas: 1
            app: scale
    strategy: {}
                app: scale
...output omitted...

A deployment configuration, typically created using either the oc new-app command or the web console, defines the same information, but in a slightly different way. Notice that an additional selector for deploymentconfig exists, and the matching deploymentconfig label is also added to the pod metadata.

If the deployment or deployment configuration resource is under version control, then modify the replicas line in the resource file and apply the changes using the oc apply command.

Whether in a deployment or a deployment configuration resource, a selector is a set of labels that all of the pods managed by the replica set or replication controller must match.

The same set of labels must be included in the pod definition that the deployment or deployment configuration instantiates. This selector is used to determine how many instances of the pod are already running in order to adjust as needed.