docker - Can I Assign Pod to a NIC?
问题描述
I have 1 master 1 node kubernetes cluster. On the node there are 2 network interface cards (in the same IP block and same sub-net but different IP).
Can i assign my pods to a special NIC ?
For example in docker we execute below command:
docker run -p 192.168.1.15:80:80 nginx
With above command nginx will run only on IP 192.168.1.15
So, can i achieve this on kubernetes?
解决方案
关于您的 docker 示例docker run -p 192.168.1.15:80:80 nginx
您可以使用没有选择器的服务
apiVersion: v1
kind: Service
metadata:
name: nginx-svc
spec:
ports:
- protocol: TCP
port: 80
targetPort: 80
由于该 Service 没有选择器,因此不会自动创建相应的 Endpoint 对象。您可以通过手动添加 Endpoint 对象,手动将服务映射到其运行的网络地址和端口:
apiVersion: v1
kind: Endpoints
metadata:
name: nginx-svc
subsets:
- addresses:
- ip: 192.168.1.15
ports:
- port: 80
推荐阅读
- python - 如何在python中的图形(字典)中找到所有派系?
- powerbi - 使用 Dax power Bi 将文本与第二行进行比较
- python - 在 Python 中读取数据框之前检查 json 文件的方向
- r - 错误:当我使用 gg4xh 库中的 facetted_pos_scales 时输入无效
- python - 如何使用 django GenericForeignKeys?
- npm - 我在终端中使用命令 npm install axios 安装 axios 时遇到问题。…但不安装…
- java - 检查函数的极限无穷大
- python - 如何检查参考路径内的 3D 图?
- git - 如何更改 Git 根目录?
- docker - 如果不暴露端口,docker DNAT 是如何工作的?