是否可以使用特定的自定义规则在Kubernetes/Docker中运行新容器? [英] Is it possible to specific custom rules for running new containers in Kubernetes/Docker?

查看:90
本文介绍了是否可以使用特定的自定义规则在Kubernetes/Docker中运行新容器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不必是kubernetes.可以是Docker.

It doesn't have to be kubernetes. It can be Docker.

我不确定这是否是正确的问题,但这是我要实现的目标:

I'm not sure if this is the right question, but this is what I want to achieve:

我想使用容器(Azure)在云中运行游戏服务器(UnrealEngine).我知道如何使用虚拟机来实现它,但是我想尝试Kubernetes. 从学习经验来看,从长远来看,使用CI/CD应该更容易.

I want to run game server (UnrealEngine) in cloud using containers (Azure). I know how to achieve it using virtual machines, but I'd like to try Kubernetes. For both learning experience and tha fact that CI/CD using it should be easier in long run.

我需要实现的目标:

  1. 客户要求配对服务来寻找其他与之合作的玩家.
  2. 匹配者找到其他参与者.
  3. 它告诉kubernetes旋转新容器并将匹配的玩家路由到它.

OR:

  1. 客户输入地图.
  2. 进入低谷门户网站.
  3. 我假设一张地图-一台服务器.因此,我想关闭以前的地图,然后使用新地图在新服务器上旋转.

使用VM虽不容易,但使用用于Azure的C#SDK即可轻松完成.

With VM while not trivial it's easy enough to do it with C# SDK for Azure.

但是在Kubernetes的情况下,我真的不知道从哪里开始寻找.一直在浏览低谷的文档,但无法真正找到我想要的东西(或者我不知道我只是在看它..).

But In case of Kubernetes I don't really know where to start looking. Been looking trough documentation, but can't really find what I'm looking for (or I don't know I just looked at it..).

我看过这篇文章: http://blog.juliaferraioli.com/2015/11/containerized- minecraft-roulette.html

但这并不是我想要的,这里的玩家是随机分布的,所有需要的容器都在运行.我想对玩家的位置以及一次运行多少实例进行更细粒度的控制.

But that's not exactly what I want, here players are distributed randomly and all needed containers are running. I want to have more fine grained controll over where players go, and how many instances there are running at once.

推荐答案

对于顶部的"OR"部分,使用Ingress控制器可以做到这一点(我脑海中的那个是haproxy,但是有一个一些实现):它的工作是成为从Internet流量到声明其兴趣的kubernetes服务的路由器.关于Ingress控制器的令人敬畏的事情是,它是通过kubernetes API与kubernetes的所有其他部分完全相同的方式进行控制的.

For the top "OR" parts, using an Ingress controller will do that (the one I have in my head is haproxy, but there are quite a few implementations): its job is to be a router from Internet traffic to the kubernetes Service(s) that declare their interest. The awesome thing about an Ingress controller is that it is controlled through kubernetes APIs in exactly the same way as all other parts of kubernetes.

所以,在我的脑海:

  1. 完全在您的设置中,因此我不会与之交谈,只是说如果为即将来临的玩家组启动新的游戏服务器很耗时,这可能是时候启动该过程了.它将创建服务(例如,名称为ClusterIPgame-1502350068,并且您需要玩游戏的所有ports:),添加任意内容的selector:,还添加(您当然可以将game: "1502350068"用作合法的Pod标签,但是由于使用的标签必须是字符串,因此请务必记住在使用的所有地方都引用它)

  1. is totally in your setup, so I won't speak to it with the exception of saying that if launching a new game server for the upcoming group of players is time consuming, this might be the time to start that process in motion. It would create the Service (named, for example, game-1502350068 of type ClusterIP, and with all the ports: you would need to play the game), add the selector: of whatever-whatever, but also game: g1502350068 (you can, of course, use game: "1502350068" as a legal Pod label, but will need to remember to quote it everywhere it is used, since labels must be strings)

这也是您考虑创建新的game-1502350068.example.com映射到上述服务的> Ingress 资源,从(可能是通配符)DNS记录创建链接,向下进入群集和服务.但请放心,目前没有与该选择器匹配的Pod,因此如果有人尝试连接,流量只会消失

This is also the time you would consider creating a new Ingress resource that maps game-1502350068.example.com to the aforementioned Service, creating the linkage from a (presumably wildcard) DNS record down into the cluster and to the Service. But don't worry, there are currently no Pods matching that selector so traffic will just die if someone attempts to connect

我刚才描述的所有内容都可以通过kubernetes API进行100%的处理,并且在您手动执行一次或两次此过程时调用kubectl --v=100会向您显示确切的端点和(我相信)确切的有效负载.然后,您可能会怀疑,kubernetes API可以将所有这些资源拆散,从而节省其他玩家的资源

Everything I just described is 100% possible through the kubernetes API, and invoking kubectl --v=100 as you do that process manually once or twice will show you the exact endpoints and (I believe) the exact payloads. Then, as you might suspect, the kubernetes API can tear all of those down, conserving resources for other players

这篇关于是否可以使用特定的自定义规则在Kubernetes/Docker中运行新容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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