What exactly is a YAML file?

YAML Ain’t Markup Language (YAML™)… what a kooky acronym but that is what it stands for.

YAML is a human-readable text-based file format that is used by Kubernetes to describe and specify the configuration of a component. At first they can look a bit daunting and confusing, but they are not. The one thing that is critical is that you have to be careful with your indentations, they are not random, the position matters and if you edit a YAML file and you do not line stuff up then you can find stuff not working. A YAML file is used to define: Services, Persistent Volume Claims, Deployments, Config Maps and those can be in individual YAML files or you can have them all in one (sometimes).

This is a sample YAML file to define a WordPress service..

apiVersion: v1
kind: Service
metadata:
  name: wordpress
  labels:
    app: wordpress
spec:
  ports:
  - port: 80
  selector:
    app: wordpress

When you are first starting out it is advised that you just take and existing YAML file and use it, making minor edits to suite your configuration, but for the most part use someone else’s example and expand on it carefully. That is not to say you can’t get out a text editor and create your own from scratch, it is more if you are starting out you will have an easier time if you just reuse someone else’s.