kubectl apply vs kubectl create? [英] kubectl apply vs kubectl create?

查看:53
本文介绍了kubectl apply vs kubectl create?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对文档的理解是:

  • kubectl create = 在集群中创建一个新的 k8s 资源
  • kubectl replace = 更新实时集群中的资源
  • kubectl apply = 如果我想做创建 + 替换 (参考)
  • kubectl create = Creates a new k8s resource in the cluster
  • kubectl replace = Updates a resource in the live cluster
  • kubectl apply = If I want to do create + replace (Reference)

我的问题是

  1. 为什么在一个集群中执行同一任务需要三个操作?
  2. 这些操作的用例是什么?
  3. 它们在内部有何不同?

推荐答案

这是两种不同的方法:

kubectl create 就是我们所说的 势在必行的管理.在这种方法中,您告诉 Kubernetes API 您想要创建、替换或删除什么,而不是您希望 K8s 集群世界的样子.

kubectl create is what we call Imperative Management. On this approach you tell the Kubernetes API what you want to create, replace or delete, not how you want your K8s cluster world to look like.

kubectl apply声明式管理方法,其中您可能已应用于活动对象的更改(即通过scale)被维护";即使您对对象应用其他更改.

kubectl apply is part of the Declarative Management approach, where changes that you may have applied to a live object (i.e. through scale) are "maintained" even if you apply other changes to the object.

您可以在 中阅读有关命令式和声明式管理的更多信息Kubernetes 对象管理 文档.

这篇关于kubectl apply vs kubectl create?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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