【问题标题】:Cannot connect to NodePort URL with minikube无法使用 minikube 连接到 NodePort URL
【发布时间】:2022-07-17 00:02:19
【问题描述】:

我只是在尝试一个非常简单的 NodePort 示例,在 Apple M1 机器上使用 minikube。我基本上是通过 minikube 创建一个单节点 k8s 集群,然后创建一个 1-pod 部署和 NodePort 服务。 NodePort URL 不断为我加载。以下是我使用的命令。

$ minikube start
????  minikube v1.25.2 on Darwin 12.4 (arm64)
✨  Automatically selected the docker driver
????  Starting control plane node minikube in cluster minikube
????  Pulling base image ...
????  Downloading Kubernetes v1.23.3 preload ...
    > preloaded-images-k8s-v17-v1...: 419.07 MiB / 419.07 MiB  100.00% 5.49 MiB
????  Creating docker container (CPUs=2, Memory=4000MB) ...
????  Preparing Kubernetes v1.23.3 on Docker 20.10.12 ...
    ▪ kubelet.housekeeping-interval=5m
    ▪ Generating certificates and keys ...
    ▪ Booting up control plane ...
    ▪ Configuring RBAC rules ...
????  Verifying Kubernetes components...
    ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
????  Enabled addons: storage-provisioner, default-storageclass
????  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default


$ kubectl create deployment nginx-deployment --image=nginxdemos/hello
deployment.apps/nginx-deployment created


$ kubectl expose deployment nginx-deployment --type=NodePort --port=80
service/nginx-deployment exposed


$ minikube service nginx-deployment
????  Starting tunnel for service nginx-deployment.
????  Opening service default/nginx-deployment in default browser...
❗  Because you are using a Docker driver on darwin, the terminal needs to be open to run it.

=> This opens the URL in the browser (e.g. http://192.168.49.2:32739/), but it keeps loading forever

当我 SSH 进入节点时,我可以毫无问题地 curl pod IP。

$ minikube ssh
Last login: Thu May 26 10:09:35 2022 from 192.168.49.1

# This is the IP of the running pod
docker@minikube:~$ curl -sI 172.17.0.3 | grep HTTP
HTTP/1.1 200 OK

我还看到服务绑定到 pod:

$ kubectl describe service nginx-deployment

Name:                     nginx-deployment
Namespace:                default
Labels:                   app=nginx-deployment
Annotations:              <none>
Selector:                 app=nginx-deployment
Type:                     NodePort
IP Family Policy:         SingleStack
IP Families:              IPv4
IP:                       10.109.174.147
IPs:                      10.109.174.147
Port:                     <unset>  80/TCP
TargetPort:               80/TCP
NodePort:                 <unset>  32739/TCP
Endpoints:                172.17.0.3:80
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

我做错了什么?

【问题讨论】:

  • 检查端口转发是否从 NodePort 32739 设置到 Pod 目标端口 80
  • 如果你在 10.109.174.147 上卷曲,你能得到任何回应吗?
  • 显示服务清单。显示 minikube 节点 ip/端口映射
  • @Nayan:可以看到 Endpoints 是“172.17.0.3:80”,也就是说 NodePort 和 Pod 端口 80 之间的端口映射已经设置好了,不是吗?

标签: kubernetes minikube


【解决方案1】:

我通过改用 Docker Desktop kubernetes 解决了这个问题。好像 minikube 不能很好地与 Apple M1 配合使用。

【讨论】:

    猜你喜欢
    • 2019-10-24
    • 2022-01-15
    • 2020-12-03
    • 2021-01-02
    • 2020-03-25
    • 2020-09-01
    • 2020-12-15
    • 2019-03-12
    • 1970-01-01
    相关资源
    最近更新 更多