<pre><code>apiVersion: v1
kind: ReplicationController
metadata:
  name: simple-rc
spec:
  replicas: 2
  selector:
    app: nginx
  template:
    metadata:
      name: simple-rc
      labels:
        app: simple-rc
        version: "1.0"
    spec:
      containers:
        - name: simple-rc
          image: nginx
          ports:
            - containerPort: 80

</code></pre>

<p>error: </p>

<pre><code>error validating "sample.yml": error validating data: 
ValidationError(ReplicationController.metadata): invalid type for io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta: got "string", expected "map"; if you choose to ignore these errors, turn validation off with --validate=false
</code></pre>

RISHI MALLIK
<p>The .spec.selector field is a label selector. A ReplicationController manages all the pods with labels that match the selector. It does not distinguish between pods that it created or deleted and pods that another person or process created or deleted. This allows the ReplicationController to be replaced without affecting the running pods.</p>

<blockquote>
  <p>If specified, the .spec.template.metadata.labels must be equal to the .spec.selector, or it will be rejected by the API. If .spec.selector is unspecified, it will be defaulted to .spec.template.metadata.labels.</p>
</blockquote>

<ul>
<li><a href="https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/#pod-selector" rel="nofollow noreferrer">Reference</a></li>
</ul>

<pre><code>spec:
  replicas: 2
  selector: # Update the selector to match labels
    app: simple-rc
    version: "1.0"
  template:
    metadata:
      name: simple-rc
      labels:
        app: simple-rc
        version: "1.0"
</code></pre>
