kubernetes nodePort不可访问问题

本文介绍了解决Kubernetes环境中因SELinux和iptables引发的问题的方法,包括使用setenforce0临时禁用SELinux,清空iptables规则并重启Docker服务,以及设置iptables转发策略,确保容器能正常访问主机文件系统。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

通常由于iptables问题和selinux问题
解决方式

setenforce 0
iptables --flush
iptables -tnat --flush
service docker restart
iptables -P FORWARD ACCEPT

官方原文:
Disabling SELinux by running setenforce 0 is required to allow containers to access the host filesystem, which is required by pod networks for example. You have to do this until SELinux support is improved in the kubelet.
翻译就是
通过setenforce 0 关闭SELinux是必须的,这样容器才可以访问主机的文件系统,例如pod的网络操作就需要访问主机文件系统。直到kubelet支持SELinux之前你都需要关闭SELinux。

iptables --flushiptables -tnat --flush是清空iptables的规则,然后重启docker后会重新加入kubernetes的iptables规则,iptables -P FORWARD ACCEPT则允许转发

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值