From the course: Certified Kubernetes Application Developer (CKAD) Cert Prep

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Generating YAML files

Generating YAML files

- All right, let's check out how to generate YAML files. As I just told you, you should not write YAML files, you should generate them. And hey, on the exam you can also copy paste them from the Kubernetes documentation. But how does generating work? Well, to generate a YAML file, you add --dry-run is client -o YAML > my.yaml. It's an argument to either the kubectl run or the kubectl create commands. Now this dry-run is client isn't actually creating anything, it just generates the code, and the code is generated in YAML format and with the redirect, you write it to the YAML file that you want to create. For example, you use a command like kubectl run mynginx --image is nginx. You really need all the arguments on the command line in this command, followed by dry-run is client -o YAML, and write that to mynginx.yaml. And next you can create the resources in the YAML file using kubectl apply -f. Let me show you. So kubectl run mynginx --image is nginx, no further properties, --dry-run…

Contents