May 2018
Intermediate to advanced
554 pages
13h 51m
English
Deployment supports not only the equality-based selector, but also the set-based selector, to specify ReplicaSet. To do that, you can write spec.selector.matchExpressions[] to specify the key and in/notin operator. For example, if you want to specify project in (poc), environment in (staging), tier notn (backend,cache), then matchExpressions would be as follows:
$ cat deploy_set_selector.yaml apiVersion: apps/v1kind: Deploymentmetadata: name: my-nginxspec: replicas: 3 selector: matchExpressions: - {key: project, operator: In, values: [poc]} - {key: environment, operator: In, values: [staging]} - {key: tier, operator: NotIn, values: [backend,cache]} template: metadata: labels:Read now
Unlock full access