serving the solutions day and night


Tuesday, August 25, 2020

Kubernetes ReplicaSet selector with matchExpressions

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 

apiVersion: apps/v1
kind: Deployment
  name: myapp-deployment_replicatset
   replicas: 3  
       app: myapp
       - {key: zone, operator: In, values: [prod, test]} 
         app: myapp           
         zone: prod           
         version: v1        
         - name: myapp-frontendmvc              
           image: makader/myapp:frontendmvc-v1              
             - containerPort: 80

No comments: