1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-06 15:46:57 +01:00
Files
openshift-docs/modules/deployments-replicationcontrollers.adoc
2019-05-13 13:57:48 +10:00

59 lines
2.0 KiB
Plaintext

// Module included in the following assemblies:
//
// * applications/deployments/what-deployments-are.adoc
[id="deployments-replicationcontrollers_{context}"]
= ReplicationControllers
A ReplicationController ensures that a specified number of replicas of a Pod are running at
all times. If Pods exit or are deleted, the ReplicationController acts to
instantiate more up to the defined number. Likewise, if there are more running
than desired, it deletes as many as necessary to match the defined amount.
A ReplicationController configuration consists of:
* The number of replicas desired (which can be adjusted at runtime).
* A Pod definition to use when creating a replicated Pod.
* A selector for identifying managed Pods.
A selector is a set of labels assigned to
the Pods that are managed by the ReplicationController. These labels are
included in the Pod definition that the ReplicationController instantiates.
The ReplicationController uses the selector to determine how many
instances of the Pod are already running in order to adjust as needed.
The ReplicationController does not perform auto-scaling based on load or
traffic, as it does not track either. Rather, this requires its replica
count to be adjusted by an external auto-scaler.
The following is an example definition of a ReplicationController:
[source,yaml]
----
apiVersion: v1
kind: ReplicationController
metadata:
name: frontend-1
spec:
replicas: 1 <1>
selector: <2>
name: frontend
template: <3>
metadata:
labels: <4>
name: frontend <5>
spec:
containers:
- image: openshift/hello-openshift
name: helloworld
ports:
- containerPort: 8080
protocol: TCP
restartPolicy: Always
----
<1> The number of copies of the Pod to run.
<2> The label selector of the Pod to run.
<3> A template for the Pod the controller creates.
<4> Labels on the Pod should include those from the label selector.
<5> The maximum name length after expanding any parameters is 63 characters.