Kubernetes for absolute biggners coures

I am trying solve exercises of replication set
root@controlplane:~# cat replicaset-definition-1.yaml
apiVersion: apps/v1

kind: ReplicaSet
metadata:
name: replicaset-1
labels:
type: frontend
spec:
template:
metadata:
names: my-app
labels:
tier: frontend
spec:
containers:
- name: nginx
image: nginx
replicas: 2
selector:
matchLabels:
tier: frontend
root@controlplane:~# kubectl apply -f replicaset-definition-1.yaml
error: error validating “replicaset-definition-1.yaml”: error validating data: [ValidationError(ReplicaSet): unknown field “replicas” in io.k8s.api.apps.v1.ReplicaSet, ValidationError(ReplicaSet): unknown field “selector” in io.k8s.api.apps.v1.ReplicaSet, ValidationError(ReplicaSet.spec.template.metadata): unknown field “names” in io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta, ValidationError(ReplicaSet.spec): missing required field “selector” in io.k8s.api.apps.v1.ReplicaSetSpec]; if you choose to ignore these errors, turn validation off with --validate=false

I have created this replica set yaml file it is throwing error can u tell me what is incorrect here

apiVersion: apps/v1

kind: ReplicaSet
metadata:
name: replicaset-1
labels:
type: frontend
spec:
template:
metadata:
names: my-app
labels:
tier: frontend
spec:
containers:
- name: nginx
image: nginx
replicas: 2
selector:
matchLabels:
tier: frontend

i


this my content of replica set file

And after watching solution video i am getting error: error parsing replicaset-definition-1.yaml: error converting YAML to JSON: yaml: line 2: mapping values are not allowed in this context’

Hello, @Aman
There are space required in “replicas” and “selector” fields.

kind:
apiVersion:
metadata:
   name:
   labels:
spec:
   template:
       metadata:
           name:
           labels:
       spec:
          containers:
           - name:
             image:
   replicas:
   selector:
     matchLabels:

You can take help of “Solution” section.

try to use these configuration
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: replicaset-1
spec:
replicas: 2
selector:
matchLabels:
tier: frontend
template:
metadata:
labels:
tier: frontend
spec:
containers:
- name: nginx
image: nginx

  1. List item

replicas is under spec with 2 space indentation