<p>While creating <code>ReplicaSet</code>, I am getting following error:</p>
<blockquote>
<p>The ReplicaSet &quot;julrs&quot; is invalid: spec.template.metadata.labels:
Invalid value: map[string]string{&quot;type&quot;:&quot;july-26&quot;}: <code>selector</code> does
not match template <code>labels</code></p>
</blockquote>
<p>Below is my yaml file replicaset.yml file</p>
<pre><code>apiVersion: apps/v1
kind: ReplicaSet
metadata:
    name: julrs
    labels:
        type: jul-26
spec:
    template:
       metadata:
           labels:
               type: july-26
       spec:
           containers:
               - name: jul-c1
                 image: nginx
    replicas: 2
    selector:
        matchLabels:
            type: jul-26
</code></pre>
<p>What am I missing? I have tried <code>ReplicationController</code> with the same yaml (without selector and using v1 version) and it was working fine.</p>

Deepak Mourya
<p>Well the yaml file should be like this</p>
<pre><code>apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: julrs
  labels:
    type: july-26
spec:
  replicas: 2
  selector:
    matchLabels:
      type: july-26 &lt;-----This 
  template:
    metadata:
      labels:
        type: july-26 &lt;-------this should be same as above
    spec:
      containers:
      - name: jul-c1
        image: nginx
</code></pre>
