Skip to content

Instantly share code, notes, and snippets.

@anderson-custodio
Last active August 15, 2019 23:08
Show Gist options
  • Save anderson-custodio/6092b654f0ffc4e70733cf92f423d10a to your computer and use it in GitHub Desktop.
Save anderson-custodio/6092b654f0ffc4e70733cf92f423d10a to your computer and use it in GitHub Desktop.

Using the kubectl run command can help in generating a YAML template

Reference: https://kubernetes.io/docs/reference/kubectl/conventions/

Create an NGINX Pod

kubectl run --generator=run-pod/v1 nginx --image=nginx

Generate POD Manifest YAML file (-o yaml). Don't create it(--dry-run)

kubectl run --generator=run-pod/v1 nginx --image=nginx --dry-run -o yaml

Create a deployment

kubectl run --generator=deployment/v1beta1 nginx --image=nginx

Generate Deployment YAML file (-o yaml). Don't create it(--dry-run)

kubectl run --generator=deployment/v1beta1 nginx --image=nginx --dry-run -o yaml

Generate Deployment YAML file (-o yaml). Don't create it(--dry-run) with 4 Replicas (--replicas=4)

kubectl run --generator=deployment/v1beta1 nginx --image=nginx --dry-run --replicas=4 -o yaml

Save it to a file - (If you need to modify or add some other details before actually creating it)

kubectl run --generator=deployment/v1beta1 nginx --image=nginx --dry-run --replicas=4 -o yaml > nginx-deployment.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment