动态kubernetes端口范围 [英] dynamic kubernetes port range

查看:439
本文介绍了动态kubernetes端口范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有不同的Kubernetes命名空间...比如10 ...我确实为某些Pod使用了动态分配的Pod端口.它们对用户不是可见"的,只能互相交流...没关系... Node vs Target ...我明白了...

I have different Kubernetes namespaces... Like, 10... I do use dynamically assign pod ports for some of my pods. They are not "visible" by the user and only speaks to each other... Which is ok... Node vs Target... I get that...

但是,对于我们的某些Pod,我想手动分配一个Node/Target端口以使其中一些可以公开访问,但是我恐怕会与Kubernetes已经分配的那个有一些冲突".不知道...

However, for some of our pods, I want to manually assign a Node/Target port to make some of them accessible publicly, but I am afraid I will have some "collision" with the one already assigned by Kubernetes that I am not aware of...

我的问题:是否可以告诉Kubernetes使用整个30000-32667端口范围,但保留一部分用于静态"使用,另一部分保留用于动态范围?答案很明显是怎么做到的.

My question: Is there a way to tell Kubernetes to use the entire 30000-32667 port range but keep a part of it for my "static" usage and the other part for the dynamic range ? Ans how to do that obviously.

推荐答案

我认为没有保留端口范围的方法.文档明确指出:

I don't think there is a way to reserve a port range. The docs clearly state:

如果需要特定的端口号,则可以在 nodePort字段,系统将为您分配该端口,否则 API交易将失败(即,您需要注意可能的情况) 端口会自己撞车.)

If you want a specific port number, you can specify a value in the nodePort field, and the system will allocate you that port or else the API transaction will fail (i.e. you need to take care about possible port collisions yourself).

但是,如果使用kubectl describe services检查当前使用的端口,然后为未使用的新手动NodePort服务选择端口,则应该没问题. Kubernetes不会尝试再次分配相同的端口.

But if you check your currently used ports with kubectl describe services and then choose ports for your new manual NodePort services that are not in use you should be fine. Kubernetes will not try to assign the same Ports again.

从长远来看,您可能希望手动控制所有服务端口或动态控制所有服务端口.在后一种情况下,通过使用从您定义的固定端口转发到您的服务的负载均衡器,可以实现更大的灵活性.

In the long term you probably want to either control all the service Ports manually or all dynamically. In the latter case you can achieve some more flexibility with using Load Balancers that forward to your service from a fixed port that you define.

这篇关于动态kubernetes端口范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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