副本集和部署都有属性replica: 3,部署和副本集有什么区别?部署是否通过底层的副本集进行?
部署配置
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-deployment
labels:
my-label: my-value
spec:
replicas: 3
selector:
matchLabels:
my-label: my-value
template:
metadata:
labels:
my-label: my-value
spec:
containers:
- name: app-container
image: my-image:latest
Run Code Online (Sandbox Code Playgroud)
副本集的配置
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: my-replicaset
labels:
my-label: my-value
spec:
replicas: 3
selector:
matchLabels:
my-label: my-value
template:
metadata:
labels:
my-label: my-value
spec:
containers:
- name: app-container
image: my-image:latest
Run Code Online (Sandbox Code Playgroud)
何时使用 ReplicaSet
ReplicaSet 可确保在任何给定时间运行指定数量的 Pod 副本。然而,部署是一个更高级别的概念,它管理 ReplicaSet 并为 Pod 提供声明性更新以及许多其他有用的功能。因此,我们建议使用 Deployments 而不是直接使用 ReplicaSet,除非您需要自定义更新编排或根本不需要更新。
这实际上意味着您可能永远不需要操作 …
我是kubernetes和微服务的新手,有2个对象Deployments和ReplicaSet。
即使阅读了它的文档和其他文章,我也仍然束手无策。
如果有Deployments,为什么我们需要a,ReplicaSet因为您可以在中指定副本集Deployment。当我删除Pod时,将根据副本集生成新Pod,就像部署一样。
就像我们只需要ReplicaSet但不需要的实际用例是什么Deployments