1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-06 06:46:26 +01:00
Files
openshift-docs/modules/deployments-replicasets.adoc
2020-08-05 03:09:24 +00:00

60 lines
1.8 KiB
Plaintext

// Module included in the following assemblies:
//
// * applications/deployments/what-deployments-are.adoc
[id="deployments-repliasets_{context}"]
= ReplicaSets
Similar to a ReplicationController, a ReplicaSet is a native Kubernetes API
object that ensures a specified number of pod replicas are running at any given
time. The difference between a ReplicaSet and a ReplicationController is that
a ReplicaSet supports set-based selector requirements whereas a replication
controller only supports equality-based selector requirements.
[NOTE]
====
Only use ReplicaSets if you require custom update orchestration or do not
require updates at all. Otherwise, use Deployments. ReplicaSets can be used
independently, but are used by deployments to orchestrate pod creation,
deletion, and updates. Deployments manage their ReplicaSets automatically,
provide declarative updates to pods, and do not have to manually manage the
ReplicaSets that they create.
====
The following is an example `ReplicaSet` definition:
[source,yaml]
----
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: frontend-1
labels:
tier: frontend
spec:
replicas: 3
selector: <1>
matchLabels: <2>
tier: frontend
matchExpressions: <3>
- {key: tier, operator: In, values: [frontend]}
template:
metadata:
labels:
tier: frontend
spec:
containers:
- image: openshift/hello-openshift
name: helloworld
ports:
- containerPort: 8080
protocol: TCP
restartPolicy: Always
----
<1> A label query over a set of resources. The result of `matchLabels` and
`matchExpressions` are logically conjoined.
<2> Equality-based selector to specify resources with labels that match the
selector.
<3> Set-based selector to filter keys. This selects all resources with key equal
to `tier` and value equal to `frontend`.