kubernetes - minikube ip 无法访问
问题描述
我创建了一项名为fleetman-webapp 的服务:
apiVersion: v1
kind: Service
metadata:
name: fleetman-webapp
spec:
selector:
app: webapp
ports:
- name: http
port: 80
nodePort: 30080
type: NodePort
还有一个名为webapp的 pod :
apiVersion: v1
kind: Pod
metadata:
name: webapp
labels:
app: webapp
spec:
containers:
- name: webapp
image: richardchesterwood/k8s-fleetman-webapp-angular:release0
我检查了minikube ip:
192.168.99.102
但是当我在浏览器中输入192.168.99.102:30080时,webapp 无法访问:
请注意,我使用的是 Ubuntu 最新版本。我进一步验证了代理和防火墙是否处于活动状态:
猫 /etc/环境:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
iptables -L:
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy DROP)
target prot opt source destination
DOCKER-USER all -- anywhere anywhere
DOCKER-ISOLATION-STAGE-1 all -- anywhere anywhere
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
DOCKER all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain DOCKER (1 references)
target prot opt source destination
Chain DOCKER-ISOLATION-STAGE-1 (1 references)
target prot opt source destination
DOCKER-ISOLATION-STAGE-2 all -- anywhere anywhere
RETURN all -- anywhere anywhere
Chain DOCKER-ISOLATION-STAGE-2 (1 references)
target prot opt source destination
DROP all -- anywhere anywhere
RETURN all -- anywhere anywhere
Chain DOCKER-USER (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
我还在 Ubuntu 中禁用了ufw,但没有成功,即 url 192.168.99.102:30080。
你能帮帮我吗?提前感谢您的回答。
解决方案
即使您在 minikube 中通过 NodePort 公开端口 30080,minikube 仍然不会公开它,因为它将使用自己的外部端口来侦听此服务。Minikube 通过隧道将服务暴露给外部世界。要找出暴露的端口:
minikube service $SERVICE_NAME
所以,在你的情况下
minikube service fleetman-webapp
推荐阅读
- protocol-buffers - gRPC 服务选项语法
- ios - 如何将一个数组添加到另一个数组
- python - 如何使用循环命令切片、创建新的 df 并以特定名称保存?
- r - 是否有从 Excel 电子表格导入现有图形的 R 函数?
- python - 如何使用 BeautifulSoup 显示隐藏的 html 元素?
- python - 试图合并两个图像,但重叠后有可见的线条
- bash - 在 bash 中读取文件并为每一行执行复制和维护序列
- android - 如何在使用 Google Places SDK 时克服重复类问题
- button - Arduino - 按下按钮时如何显示表格?
- python - 试图只抓取每个表格行中的第一个 href