WSL2环境下Minikube NodePort服务curl超时问题求助
Minikube NodePort服务连接超时问题
环境
- WSL2
- minikube
- Windows 11
- Calico插件
- Docker-Desktop
问题
执行curl http://$(minikube ip):32000时出现连接超时,已查阅Stack Overflow相关问题但均不适用。
操作步骤
- 创建Nginx部署及对应的Service:
$ k create deploy nginxsvc --image=nginx --replicas=3 $ k expose deploy nginxsvc --port=80
- 编辑该Service,将类型修改为NodePort。
相关命令输出
k get svc输出
$ k get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 18d nginxsvc NodePort 10.103.11.225 <none> 80:32000/TCP 19m regular-encourager NodePort 10.102.236.129 <none> 8080:32058/TCP 15d
curl命令执行结果
$ curl http://$(minikube ip):32000 curl: (28) Failed to connect to 192.168.49.2 port 32000: Connection timed out
k describe svc nginxsvc输出
$ k describe svc nginxsvc Name: nginxsvc Namespace: default Labels: app=nginxsvc Annotations: <none> Selector: app=nginxsvc Type: NodePort IP Family Policy: SingleStack IP Families: IPv4 IP: 10.103.11.225 IPs: 10.103.11.225 Port: <unset> 80/TCP TargetPort: 80/TCP NodePort: <unset> 32000/TCP Endpoints: 10.244.1.233:80,10.244.1.234:80,10.244.1.235:80 Session Affinity: None External Traffic Policy: Cluster Events: <none>
k get svc nginxsvc -o yaml输出
apiVersion: v1 kind: Service metadata: creationTimestamp: "2023-03-28T23:18:04Z" labels: app: nginxsvc name: nginxsvc namespace: default resourceVersion: "531373" uid: fcd7960e-8610-4099-a014-9b4ce94cdec2 spec: clusterIP: 10.103.11.225 clusterIPs: - 10.103.11.225 externalTrafficPolicy: Cluster internalTrafficPolicy: Cluster ipFamilies: - IPv4 ipFamilyPolicy: SingleStack ports: - nodePort: 32000 port: 80 protocol: TCP targetPort: 80 selector: app: nginxsvc sessionAffinity: None type: NodePort status: loadBalancer: {}
内容的提问来源于stack exchange,提问作者likejudo
相关产品推荐
相关产品推荐

