Tuesday, June 3, 2025

kubernetes dry run to create a yaml file

If you need to create a yaml file from scratch for a nginx image a quick and easy way to do this is to run

k run nginx-yaml --image=nginx --dry-run=client --output=yaml

If you don't remember how to do this off the top of your head you can run a help command on dry run

k run -h | less

To save the yaml output to a file to run with an apply or create statement it would look like this.

k run nginx-yaml --image=nginx --dry-run=client --output=yaml > nginx.yaml

This is very fast and saves you from having to google or dig through the kubernetes docs.

No comments:

Post a Comment

Kubernetes Service

 What is the point of a Service in Kubernetes Accessing a pod by name or IP directly is fragile and not recommended for long-term connectiv...