可以进行“空运行".验证文件? [英] Possible to do a "dry run" validation of files?

查看:83
本文介绍了可以进行“空运行".验证文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Kubernetes(服务,ReplicationController等)中创建对象之前,我想测试对象的JSON或YAML规范是否有效.但是我不想真正创建对象.

Before creating an object in Kubernetes (Service, ReplicationController, etc.), I'd like to test that the JSON or YAML specification of the object is valid. But I don't want to actually create the object.

是否有一些人可以进行空运行",等同于运行kubectl create --validate=true -f file.json,但是只是让我知道它通过了验证,而不是实际创建它?

Is there some to do a "dry run" that would be equivalent to running kubectl create --validate=true -f file.json, but would just let me know that it passes validation, and not actually create it?

理想情况下,如果我可以通过API做到这一点,并且不需要使用kubectl,那就太好了.但是如果需要我使用kubectl,我可以使其工作.

Ideally, it would be great if I could do this via API, and not require the use of kubectl. But I could make it work if it required me to use kubectl.

谢谢.

推荐答案

这对我有用(kubernetes 1.7和1.9):

This works for me (kubernetes 1.7 and 1.9):

kubectl apply --validate=true --dry-run=true --filename=task.yaml

这篇关于可以进行“空运行".验证文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆