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

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

问题描述

我一直在使用type:deployment创建pod,但是我看到一些文档使用type: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正在写入永久数据,这些数据将无法重新启动,或者 您的广告连播的期限很短),您可以创建一个广告连播 直接使用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有什么用?您能以某种方式引用部署中的Pod吗?我没找到办法. Pod似乎提供了一些额外的元数据,但没有任何部署选项,例如replica或重新启动策略.不保留数据,在重新启动后仍然存活的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.

推荐答案

在Kubernetes API中,Pod和Deployment都是成熟的对象.部署通过副本集管理创建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天全站免登陆