//自动测试命令的正确性,并不执行创建
[root@localhost demo]# kubectl run nginx-deployment --image=nginx --port=80 --replicas=3 --dry-run
kubectl run --generator=deployment/apps.v1beta1 is DEPRECATED and will be removed in a future version. Use kubectl create instead.
deployment.apps/nginx-deployment created (dry run)
//查看生成yaml格式
[root@localhost demo]# kubectl run nginx-deployment --image=nginx --port=80 --replicas=3 --dry-run -o yaml
//查看生成json格式
[root@localhost demo]# kubectl run nginx-deployment --image=nginx --port=80 --replicas=3 --dry-run -o json[root@localhost demo]# kubectl run nginx-deployment --image=nginx --port=80 --replicas=3 --dry-run -o yaml > my-deployment.yaml
kubectl run --generator=deployment/apps.v1beta1 is DEPRECATED and will be removed in a future version. Use kubectl create instead.
[root@localhost demo]# ls
my-deployment.yaml nginx-deployment.yaml nginx-service.yaml
//将现有的资源生成模板导出
[root@localhost demo]# kubectl get deploy/nginx --export -o yaml
//保存到文件中
[root@localhost demo]# kubectl get deploy/nginx --export -o yaml > my-deploy.yaml
//查看字段帮助信息
[root@localhost demo]# kubectl explain pods.spec.containers