<p>I am trying to used set based selectors for replica set in kubernetes. I am not able to use match expressions for setting the filter condition.</p>
<p>Replica set yaml file.</p>
<pre><code># ngnix-replication-set.yaml
apiVersion: apps/v1
kind: ReplicaSet
metadata:
    name: nginx-rs
    # label not required for RC unless it's being referred to somewhere else.
spec:
    replicas: 3
    selector: # set based selector, can be used to select multiple options in single selection
         matchLabels :
            app : nginx
        ** matchExpressions :   # match expressions are not working  
         -{key:environment,operator:In,values:[dev]}
         -{key: tier, operator: NotIn, values: [frontend,backend]}  **
    template :
        metadata:
            name: nginx-pod
            labels:
                app: nginx  #this spec is used in selector
                tier: server
                environment : dev
        spec:
            containers:
            -   name: nginx-container
                image : nginx
                ports:
                -   containerPort: 80   
</code></pre>
<p>Error:</p>
<blockquote>
<p>ngnix-replication-set.yaml&quot;: error validating data: ValidationError(ReplicaSet.spec.selector.matchExpressions): invalid type for io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector.matchExpressions: got &quot;string&quot;, expected &quot;array&quot;; if you choose to ignore these errors, turn validation off with --validate=false</p>
</blockquote>

Raptor0009
<p>From the docs <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#resources-that-support-set-based-requirements" rel="nofollow noreferrer">here</a> this seems like a indentation issue. Below should work.</p>

<pre><code>    ...
    selector:
      matchLabels:
        app: nginx
      matchExpressions:  
        - {key: environment, operator: In, values: [dev]}
        - {key: tier, operator: NotIn, values: [frontend,backend]}
    ...
</code></pre>
