本文介绍了Kubernetes Pods与Google Cloud中的部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果这个问题听起来很明显,我深表歉意,但是Kubernetes和Google云文档在某些地方非常令人困惑和矛盾.

My apologies if this question sounds obvious, but the Kubernetes and Google cloud documentation is extremely confusing and contradictory in places.

无论如何,我已经将Dockerized网络服务器推送到我的私有Google Container Registry中.我希望该容器在死后重新启动,但在任何给定时刻都只需要运行一个实例即可.此外,有很多环境变量需要定义,以便正确配置服务器.

Anyway, I have pushed a Dockerized web-server to my private Google Container Registry. I want this container to be restarted if it dies, but I only need one single instance to be running at any given moment. Moreover, there's a bunch of environment variables that need to be defined for the server to be correctly configured.

我已经创建了一个新集群.但是我从这里去哪里呢?一些教程说一个应该声明Pod和服务文件,但是下一个教程说一个不应该直接声明Pod,而应该使用部署.结果是我非常困惑.

I have already created a new cluster. But where do I go from here? Some tutorials say one should declare pod and service files, but then the next tutorial says one shouldn't declare pods directly but use deployments instead. The result is that I'm terribly confused.

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

What's the best approach for this simple use case? Also, what is the recommended documentation for using Kubernetes in Google Cloud? (Google's official docs seem out of date.)

推荐答案

根据您的描述,我建议您使用部署,其中replicas设置为1.部署将确保始终有一个Pod实例在运行.您可以定义环境变量在部署清单的 pod模板规范中.

Based on your description, I would suggest you use a 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 spec of your Deployment manifest.

在文档中,您可能还会看到使用复制控制器的建议.出于相同的目的.这绝对是一个选项,但是部署被视为成功到复制控制器,此时通常推荐.

In the documentation, you might also see suggestions to use replication controllers for the same purpose. This is definitely an option but Deployments are considered the successor to replication controllers and are usually recommended at this point.

裸露的豆荚不应该成为耐用,并且在出现节点故障或其他驱逐情况下不会重新启动.

A bare pod is not intended to be durable and will not be restarted in the case of a node failure or other type of eviction.

文档在许多地方都是过时的,但据我所知,权威位置(甚至对于GKE)是 http://kubernetes.io/docs/.

The documentation is out-of-date in many places but, as far as I know, the authoritative location (even for GKE) is http://kubernetes.io/docs/.

这篇关于Kubernetes Pods与Google Cloud中的部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-01 14:14