YML File

YML file is used to define any object in kubernetes. It has following basic and mandatory fields.

apiVersion: v1
kind: Pod
metadata:
    name: mypod
    labels:
        type: frontend
        
spec:
    containers:
        - name: nginx-container
          image: nginx

apiVersion tells which api version to use for a particular resource. Following table shows api version for different kind of resources.

KindVersion
Podv1
Servicev1
Deploymentapps/v1
ReplicaSetapps/v1

metadata contains information about the resource which consists of keys like name and labels. labels can have any key value pairs. labels help distinguish resources.

speccontainers specifications for the resources and it will be different for different kind. In this case of Pod, it has containers.