7

Kubectl: Dry Run – Client | Server – Command Examples

 1 year ago
source link: https://www.shellhacks.com/kubectl-dry-run-client-server-command-examples/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Kubectl: Dry Run – Client | Server – Command Examples

A kubectl command can be used to create, delete or updated resources on a Kubernetes cluster.

With the --dry-run=(client|server) flag, the kubectl command can be used to only preview an object, without really submitting it to the Kubernetes cluster.

The dry-run mode is useful to see what will the kubectl command do without actually changing anything.

This short note shows different examples of how to run the kubectl command in the dry-run mode.

Cool Tip: How to increase a verbosity of the kubectl command! Read more →

Kubectl Dry Run

Use the --dry-run=client or --dry-run=server options with the kubectl command to see what it will do, without actually changing anything, for example:

$ kubectl apply -f deployment.yaml --dry-run=client
Option Description
--dry-run=client A local dry-run, without accessing the Kubernetes cluster. In this case the object won’t be validated by the Kubernetes API server.
--dry-run=server The object will be sent to the Kubernetes cluster for validation, but as it is a dry-run mode, nothing actually will be changed.

The dry-run can also be used with a Kustomize, for example:

$ kubectl apply -k <directory> --dry-run=server

The dry-run with the -o yaml option can be used to print the object in YAML:

$ kubectl apply -k <directory> --dry-run=client -o yaml

To save it to a file, execute:

$ kubectl apply -k <directory> --dry-run=client -o yaml > manifest.yaml
Was it useful? Share this post with the world!

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK