首页 > 解决方案 > 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

你能帮帮我吗?提前感谢您的回答。

标签: kuberneteskubectlminikube

解决方案


即使您在 minikube 中通过 NodePort 公开端口 30080,minikube 仍然不会公开它,因为它将使用自己的外部端口来侦听此服务。Minikube 通过隧道将服务暴露给外部世界。要找出暴露的端口:

minikube service $SERVICE_NAME

所以,在你的情况下

minikube service fleetman-webapp

推荐阅读