Api version in yaml file

Hello,

Why is the apiVersion in the yaml file indicated as v1 ?

In which YAML file? We need some context here.

I am referring to the lesson on ‘Pods with YAML’ which defines

apiVersion:
kind:
metadata:
Spec:

I see that the YAML used to define the replicaset also used apiVersion as V1

Thats my first question.

Also, my second is labels under the metadata.
For example , if a replicaset is being created from a yaml file then the definition could be:

metadata:
name: myapp-replicaset
labels:
app: myapp

What the the labels that can be attached to pods/replicasets as a best practice?

Thanks

All resources have an API version. This allows for new versions (usually enhancements) to be added at a later date. The concept is covered in the CKAD course in the Security section, but for now just accept the apiVersion to use “as-is”.

The values of labels are up to you. Labels are user data for categorization purpose and you normally assign them some business meaning. So you might label some application’s pods with

department: finance
application: payroll

then it is apparent that this workload is the finance deportment’s payroll application.

The only rules on labels is when they are used to match one thing to another, then they must be the same on both “things”. A replicaset (or service or deployment), finds the pods it wants to control by matching labels, via a selector or matchLabels depending an the owning resource type.

Press on with the course and it will become clearer.