What is kubectl and when is it used?

Q: When do you use it?

A: All the time!

The Kubernetes command-line tool, kubectl, allows you to run commands against Kubernetes clusters. You can use it to do a whole bunch of things, however when you start out you will mostly use it to apply YAML files.

kubectl apply -f foobar.yaml