找了段解释如下:

Kubernetes Service vs Deployment What's the difference between a
Service and a Deployment in Kubernetes?

A deployment is responsible for keeping a set of pods running.

A service is responsible for enabling network access to a set of pods.

We could use a deployment without a service to keep a set of identical
pods running in the Kubernetes cluster. The deployment could be scaled
up and down and pods could be replicated. Each pod could be accessed
individually via direct network requests (rather than abstracting them
behind a service), but keeping track of this for a lot of pods is
difficult.

We could also use a service without a deployment. We'd need to create
each pod individually (rather than "all-at-once" like a deployment).
Then our service could route network requests to those pods via
selecting them based on their labels.

直接翻译下就是:

depoyment负责保持一组Pod运行。
service负责启用对一组Pod的网络访问。

我们可以使用没有服务的部署来保持一组相同的Pod在Kubernetes集群中运行。 可以按比例放大和缩小部署,还可以复制Pod。 可以通过直接的网络请求(而不是将它们抽象到服务之后)分别访问每个Pod,但是要跟踪很多Pod很难。

我们也可以在没有部署的情况下使用服务。 我们需要分别创建每个Pod(而不是像部署那样“一次全部”创建)。 然后,我们的服务便可以根据标签的标签选择网络请求,将网络请求路由到这些Pod。

服务和部署是不同的,但是它们可以很好地协同工作。

换个方式理解就是:depoyment就是用容器镜像创的实例, service负责访问这些实例,可以将deployment的端口通过端口暴露给其它服务或外界网络。

标签: k8s

相关文章

添加新评论