LAB Question - RS and Selectors

Can someone please clarify something on the LABs in CKA course.

I am wondering why it says to change the selector in (LAB 2) but the label in LAB 8.

They are both dealing with ReplicaSets. I know that they must match but is there a reason for choosing one over the other in each of these cases. Thank you in advance.


LAB 2 ReplicaSets

Fix the issue in the replicaset-definition-2.yaml file and create a ReplicaSet using it.

apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: replicaset-2
spec:
replicas: 2
selector:
matchLabels:
tier: frontend (this is the type of POD, change to nginx)
template:
metadata:
labels:
tier: nginx (this is the label for the POD)
spec:
containers:
- name: nginx
image: nginx

kubectl create -f /root/replicaset-definition-2.yaml
The ReplicaSet " replicaset-definition-2" is invalid: spec.template.metadata.labels: Invalid value: map[string]string{"tier:“nginx”}: selector does not match template labels

The highlighted lines should match, both should be nginx. Then apply change.
kubectl apply -f /root/replicaset-definition-2.yaml

LAB 8 Labels and Selectors

A ReplicaSet definition file is given replicaset-definition-1.yaml. Attempt to create the replicaset; you will encounter an issue with the file. Try to fix it.
Once you fix the issue, create the replicaset from the definition file.

kubectl create -f replicaset-definition-1.yaml
The ReplicaSet “replicaset-1” is invalid: spec.template.metadata.labels: Invalid value: map[string]string{“tier”:“nginx”}: selector does not match template labels

apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: replicaset-1
spec:
replicas: 2
selector:
matchLabels:
tier: front-end
template:
metadata:
labels:
tier: nginx (change to front-end)
spec:
containers:
- name: nginx
image: nginx
kubectl apply -f replicaset-definition-1.yaml

I’d say it’s arbitrary. As you say: they must match. Which you change to is apparently lab creator’s choice, not Kuberetes.

Thank you, I thought that was the case but since I am eventually going for certification I wanted to be sure.

Also through my research to see if this was answered I luckily saw we have a set of Mock exams separate from the course for extra help. Glad I caught that.