kubectl 中的要点之一 best practices section in Kubernetes Docs说明如下:
Pin to a specific generator version, such as
kubectl run --generator=deployment/v1beta1
但在文档中,我们了解到,除了 Pod 之外,不推荐使用 --generator
选项,并且它将在未来版本中删除。
为什么要这样做?生成器不会让为部署、服务和其他资源的资源定义创建模板文件变得更容易吗? kubernetes 团队建议什么替代方案?文档中没有这个:(
最佳答案
如果您想使用的不仅仅是 pod(例如部署),
kubectl create
是推荐的替代方案。
https://kubernetes.io/docs/reference/kubectl/conventions/#generators说:
Note:
kubectl run --generator
except forrun-pod/v1
is deprecated in v1.12.
This pull请求包含生成器(除了 run-pod/v1
)被弃用的原因:
The direction is that we want to move away from
kubectl run
because it's over bloated and complicated for both users and developers. We want to mimicdocker run
withkubectl run
so that it only creates a pod, and if you're interested in other resourceskubectl create
is the intended replacement.
关于kubernetes - kubectl '--generator' 选项的推荐替代方案是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57658593/