当前位置:网站首页>了解网络命名空间
了解网络命名空间
2022-07-17 00:16:00 【老段工作室】
我们下馆子吃饭,在大厅有很多桌子,那么这些人共享一个"吃饭空间"。
如果我们去包间吃饭,每一个包间都是一个"吃饭空间",包间和包间,包间和大厅之间都是独立的,互不干扰的。
对于一个系统来说,这个系统里所有的应用不管是微信还是QQ,他们“都在大厅吃饭”,他们共享一个“吃饭空间”,我们所要说的网络空间就类似于这里的“吃饭空间”。
如果在这里如果跑两个web应用程序,比如先运行了nginx,再运行apache,因为他们是在同一个网络空间里的,所以apache是运行不起来的,因为会造成端口冲突,一山不能容二虎。
如果我们在宿主机里运行了三台虚拟机,宿主机的网络空间是“大厅”,每个虚拟机都是“包间”,他们有自己的独立网络空间,所以我们在宿主机上运行了nginx,在三台虚拟机上分别运行nginx或者apache也不会造成冲突,因为他们分别在自己的网络空间里。
对应的容器也是一样。
如果我们在宿主机里运行了三个容器,宿主机的网络空间是“大厅”,每个容器都是“包间”,他们有自己的独立网络空间,所以我们在宿主机上运行了nginx,在三台虚拟机上分别运行nginx或者apache也不会造成冲突,因为他们分别在自己的网络空间里。
如果我们把容器C1和C2的头都给它“剪掉”,如同把两个包间的门都给拆掉,那么这些容器也就共享了宿主机的网络空间了。假设在c1里运行了nginx的话,他占用的就是宿主机的端口80,那么C2或者宿主机就不能运行nginx或者apache了,因为他们共享一个网络空间,端口80已经被占用了,但是这并不影响C3上运行apache或者nginx。
对于一些C/S架构的应用来说,我们把客户端安装在k8s集群里以pod方式运行,服务器可能是在集群之外的某主机或者虚拟机上运行,如下图。
然后就会有人反映说,这些代理可以连接到服务器,但是服务器联系不到这些代理那么该怎么办?其实我们在创建这些代理用的pod时,就设置这些pod使用宿主机的网络空间即可,即在pod的.spec.下添加hostNetwork: true,这样访问服务器的的IP即可访问到这些pod了。
边栏推荐
- 解决WIN10连接共享打印机出现0x00000709的错误
- PXE automated installation
- This article only commemorates the modulus of negative numbers
- Leetcode buckle classic question - 42 Connect rainwater
- Understand HTTP cache in 30 minutes
- Plant a seed and grow into a towering b+ tree ten years later
- [unity Editor Extension] displays the memory size of all files in the resource directory
- Let's learn about awk~
- HCIP第一天_HCIA复习
- Leetcode buckle classic topic - 82 Maximum rectangle in column chart
猜你喜欢
使用Grafana8.5.2显示zabbix6.0的信息
Use of sqlmap
PHP pseudo protocol for command execution
[solved] after referring to the local MySQL and forgetting the password, [server] --initialize specified but the data directory has files in it Aborti
安装软件提示无法定位程序输入点AddDllDirectory于动态链接库Kernel32.dll上(文末有下载地址)
[solution] the local Group Policy Editor (gpedit.msc) in Win 11 cannot be opened
Understand HTTP cache in 30 minutes
Use JMeter to test services based on websocket protocol
PowerStor500T报错0x01806803
Circular statements and functions of shell scripts
随机推荐
Known preorder traversal, preorder traversal, find the sequence traversal of the tree
Firewalld 防火墙
摇摆摇摆~防火墙
Dynamic display of digital tube stopwatch of single chip microcomputer
HCIP第一天_HCIA复习
[solution] the local Group Policy Editor (gpedit.msc) in Win 11 cannot be opened
MySQL差删改查用户登录修改密码
Let's learn about awk~
使用Grafana8.5.2显示zabbix6.0的信息
Chapter 1 - multi agent system
Test points of login function
RHCE-ansible-第一次作业
2022.6.28-database-1 Isolation level of database
正则、扩展表达式,sed文本处理器与awk工具、用脚本改IP地址
shell脚本之条件语句
[tools] unity quickly starts to make the artifact tilemap of 2D and 2.5D games
The difference between cookies and sessions
Flyway的SaaS多租户实现方案
Server knowledge (details)
Simple use case writing specification