ReplicaSet is a tool to manage the pod replicas and update strategies, and it is more flexible than the replication controller.
It provides set-based labels selection support instead of the equality-based labels (ReplicationController).
With equality-based (a replication controller) labels support, you can match labels only with an "is equal" or "is not equal" assertion.
Match a group of pods that has a label zone with the value prod or test, but not both of them
With a set-based labels selection, you can express more powerful assertions, like in, not in, or exists.
Match all the pods with the prod label in prod and test, using the matchExpressions property of the selector
deployment_replicaset.yaml
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp-deployment_replicatset
spec:
replicas: 3
selector:
matchLabels:
app: myapp
matchExpressions:
- {key: zone, operator: In, values: [prod, test]}
template:
metadata:
labels:
app: myapp
zone: prod
version: v1
spec:
containers:
- name: myapp-frontendmvc
image: makader/myapp:frontendmvc-v1
ports:
- containerPort: 80
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp-deployment_replicatset
spec:
replicas: 3
selector:
matchLabels:
app: myapp
matchExpressions:
- {key: zone, operator: In, values: [prod, test]}
template:
metadata:
labels:
app: myapp
zone: prod
version: v1
spec:
containers:
- name: myapp-frontendmvc
image: makader/myapp:frontendmvc-v1
ports:
- containerPort: 80
No comments:
Post a Comment