Kubernetes Pods 与 Google 云中的部署

Kubernetes Pods vs Deployments in Google Cloud

如果这个问题听起来很明显,我深表歉意,但 Kubernetes 和 Google 云文档在某些地方非常混乱和矛盾。

无论如何,我已经将 Dockerized 网络服务器推送到我的私人 Google 容器注册表。我希望这个容器在它死亡时重新启动,但我只需要一个实例在任何给定时刻为 运行。此外,为了正确配置服务器,需要定义一堆环境变量。

我已经创建了一个新集群。但是我从这里去哪里呢?一些教程说应该声明 pod 和服务文件,但下一教程说不应该直接声明 pods 而是使用部署。结果我一头雾水

这个简单用例的最佳方法是什么?另外,在 Google Cloud 中使用 Kubernetes 的推荐文档是什么? (Google 的官方文档似乎已过时。)

根据您的描述,我建议您使用部署清单的 Deployment with replicas set to 1. The Deployment will ensure that there is always one instance of your pod running. You can define your environment variables in the pod template 规范。

在文档中,您可能还会看到此时使用 replication controllers for the same purpose. This is definitely an option but Deployments are considered the successor to replication controllers and are usually recommended 的建议。

裸 pod 不打算 durable 并且在节点故障或其他类型的驱逐的情况下不会重新启动。

该文档在很多地方都已过时,但据我所知,权威位置(即使对于 GKE)是 http://kubernetes.io/docs/

@ryan 的回答很清楚。

要拥有持久的 pod,必须使用 Deployments 创建它。

A​​ Deployment 通常更可取,因为它定义了一个 ReplicaSet 以确保所需数量的 Pods 始终可用并指定替换 Pods 的策略,在您的情况下,它是 one.

如果您在没有 Deployment 的情况下直接创建 pod,则必须手动创建和管理 pods
在节点故障或 Pod 终止的情况下,Pod 类型的对象不会被重新调度(或自我修复)。

您可以改用 replica set,但它不如 Deployment 灵活。