为什么我需要使用 kubectl apply 保存配置?
Why do I need save-config with kubctl apply?
kubectl apply <file.yaml> --save-config
创建或更新部署并将部署保存为元数据。
文档中说
--save-config[=false]: If true, the configuration of current object will be saved in its annotation. This is useful when you want to perform kubectl apply on this object in the future.
为什么我需要 save-config
?如果我不 --save-config
.
,我仍然可以使用 kubectl apply
更新我的部署
kubectl 应用
kubectl apply
使用注释中的数据 kubectl.kubernetes.io/last-applied-configuration
查看例如自上次申请以来是否删除了任何字段。这是必需的,因为某些字段或注释可能已通过例如在集群中实时添加。一个控制器或变异的 webhook。
参见例如Understanding the Kubectl Apply Command
I can still update my deployment using kubectl apply if I do not --save-config
是的,--save-config
仅在从 强制性 工作流程迁移时使用。请参阅下面的更多详细信息。以下 kubectl apply
命令不需要 --save-config
标志,因为注释已经存在。
使用 kubectl 的工作流
使用 Kubernetes 配置时,可以通过多种方式完成,它们都是 强制性 或 声明性:
- Managing Kubernetes Objects Using Imperative Commands
- Imperative Management of Kubernetes Objects Using Configuration Files
- Declarative Management of Kubernetes Objects Using Configuration Files
kubectl apply
用于声明式配置管理。
从命令式配置管理迁移到声明式配置管理
使用带有 --save-config
标志的 kubectl
是一种将配置写入 kubectl apply
使用的注释 kubectl.kubernetes.io/last-applied-configuration
的方法。这在从 命令式 迁移到 声明式 工作流时很有用。
kubectl apply <file.yaml> --save-config
创建或更新部署并将部署保存为元数据。
文档中说
--save-config[=false]: If true, the configuration of current object will be saved in its annotation. This is useful when you want to perform kubectl apply on this object in the future.
为什么我需要 save-config
?如果我不 --save-config
.
kubectl apply
更新我的部署
kubectl 应用
kubectl apply
使用注释中的数据 kubectl.kubernetes.io/last-applied-configuration
查看例如自上次申请以来是否删除了任何字段。这是必需的,因为某些字段或注释可能已通过例如在集群中实时添加。一个控制器或变异的 webhook。
参见例如Understanding the Kubectl Apply Command
I can still update my deployment using kubectl apply if I do not --save-config
是的,--save-config
仅在从 强制性 工作流程迁移时使用。请参阅下面的更多详细信息。以下 kubectl apply
命令不需要 --save-config
标志,因为注释已经存在。
使用 kubectl 的工作流
使用 Kubernetes 配置时,可以通过多种方式完成,它们都是 强制性 或 声明性:
- Managing Kubernetes Objects Using Imperative Commands
- Imperative Management of Kubernetes Objects Using Configuration Files
- Declarative Management of Kubernetes Objects Using Configuration Files
kubectl apply
用于声明式配置管理。
从命令式配置管理迁移到声明式配置管理
使用带有 --save-config
标志的 kubectl
是一种将配置写入 kubectl apply
使用的注释 kubectl.kubernetes.io/last-applied-configuration
的方法。这在从 命令式 迁移到 声明式 工作流时很有用。