Pod 和部署之间有什么区别? [英] What is the difference between a pod and a deployment?

查看:24
本文介绍了Pod 和部署之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在用 type:deployment 创建 pod,但我看到一些文档使用 type:pod,更具体地说是 多容器 Pod 的文档:

I have been creating pods with type:deployment but I see that some documentation uses type:pod, more specifically the documentation for multi-container pods:

apiVersion: v1
kind: Pod
metadata:
  name: ""
  labels:
    name: ""
  namespace: ""
  annotations: []
  generateName: ""
spec:
  ? "// See 'The spec schema' for details."
  : ~

但是要创建 pod,我可以只使用 部署类型:

But to create pods I can just use a deployment type:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: ""
spec:
  replicas: 3
  template:
    metadata:
      labels:
        app: ""
    spec:
      containers:
        etc

我注意到 pod 文档说:

I noticed the pod documentation says:

create命令可以直接创建pod,也可以通过部署创建一个或多个 pod.强烈推荐您使用部署来创建您的 pod.它监视失败pods 并将根据需要启动新的 pods 以维护指定的数字.如果您不希望 Deployment 监控您的 pod(例如您的pod 正在写入非持久性数据,这些数据在重启后将无法生存,或者你的 pod 是非常短暂的),你可以创建一个 pod直接使用 create 命令.

The create command can be used to create a pod directly, or it can create a pod or pods through a Deployment. It is highly recommended that you use a Deployment to create your pods. It watches for failed pods and will start up new pods as required to maintain the specified number. If you don’t want a Deployment to monitor your pod (e.g. your pod is writing non-persistent data which won’t survive a restart, or your pod is intended to be very short-lived), you can create a pod directly with the create command.

注意:我们建议使用部署来创建 Pod.你应该使用仅当您不想创建部署时才执行以下说明.

Note: We recommend using a Deployment to create pods. You should use the instructions below only if you don’t want to create a Deployment.

但这提出了一个问题,kind:pod 有什么用?你能以某种方式在部署中引用 pods 吗?我没有看到办法.看起来您使用 pod 获得的是一些额外的元数据,但没有任何部署选项,例如 replica 或重启策略.不保留数据的 pod 有什么好处,可以在重启后幸存下来?我想我也可以创建一个带有部署的多容器 Pod.

But this raises the question of what kind:pod is good for? Can you somehow reference pods in a deployment? I didn't see a way. It looks like what you get with pods is some extra metadata but none of the deployment options such as replica or a restart policy. What good is a pod that doesn't persist data, survives a restart? I think I'd be able to create a multi-container pod with a deployment as well.

推荐答案

Pod 和 Deployment 都是 Kubernetes API 中成熟的对象.Deployment 通过 ReplicaSets 管理创建 Pod.归结为 Deployment 将使用从模板中获取的规范创建 Pod.您不太可能需要直接为生产用例创建 Pod.

Both Pod and Deployment are full-fledged objects in the Kubernetes API. Deployment manages creating Pods by means of ReplicaSets. What it boils down to is that Deployment will create Pods with spec taken from the template. It is rather unlikely that you will ever need to create Pods directly for a production use-case.

这篇关于Pod 和部署之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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