kubectk apply / create
with --dry-run
option, you can check whether manifest file is correctly or not without without persisting the resource into your cluster.--dry-run
has three options: none
, server
, client
. I will try to run with these options.
1 | apiVersion: apps/v1 |
dry-run: none (default)
1
2sh-3.2$ kubectl apply -f nginx-deployment.yaml --dry-run=none
The Deployment "nginx" is invalid: spec.template.spec.containers[0].ports[0].containerPort: Invalid value: -1: must be between 1 and 65535, inclusivedry-run: client
1
2sh-3.2$ kubectl apply -f nginx-deployment.yaml --dry-run=client
deployment.apps/nginx created (dry run)If client strategy, only print the object that would be sent, without sending it.
So you don’t know the syntax of manifest file is correct or not.dry-run: server
1
2sh-3.2$ kubectl apply -f nginx-deployment.yaml --dry-run=server
The Deployment "nginx" is invalid: spec.template.spec.containers[0].ports[0].containerPort: Invalid value: -1: must be between 1 and 65535, inclusiveIf server strategy, submit server-side request without persisting the resource.
The syntax of manifest file will be checked.