kubernetes Minikube IP拒绝从浏览器连接

q5iwbnjs  于 2023-08-03  发布在  Kubernetes
关注(0)|答案(1)|浏览(153)

我是Kubernetes的新手。我正在学习一个教程,我需要在kuberenetes集群中运行一个服务。运行minikube start后,得到以下输出:

> 😄  minikube v1.29.0 on Ubuntu 20.04 (vbox/amd64) ✨  Automatically
> selected the docker driver. Other choices: none, ssh 📌  Using Docker
> driver with root privileges 👍  Starting control plane node minikube
> in cluster minikube 🚜  Pulling base image ... 🔥  Creating docker
> container (CPUs=2, Memory=2200MB) ... 🐳  Preparing Kubernetes v1.26.1
> on Docker 20.10.23 ...
>     ▪ Generating certificates and keys ...
>     ▪ Booting up control plane ...
>     ▪ Configuring RBAC rules ... 🔗  Configuring bridge CNI (Container Networking Interface) ...
>     ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5 🔎  Verifying Kubernetes components... 🌟  Enabled addons:
> default-storageclass, storage-provisioner 🏄  Done! kubectl is now
> configured to use "minikube" cluster and "default" namespace by
> default

字符串
然后分别运行kubectl apply -f client-node-port.yamlkubectl apply -f client-pod.yaml
client-node-port.yaml看起来像这样:

apiVersion: v1
kind: Service
metadata:
  name: client-node-port
spec:
  type: NodePort
  ports:
    - port: 3050
      targetPort: 3001
      nodePort: 31515
  selector: 
    component: web


client-pod.yaml文件看起来像这样:

apiVersion: v1
kind: Pod
metadata:
  name: client-pod
  labels:
    component: web
spec:
  containers:
    - name: client
      image: dibyajyoti47/multi-client
      ports:
        - containerPort: 3001
      imagePullPolicy: Always


然后运行命令minikube ip,输出为192.168.49.2。之后,我去浏览器与url 192.168.49.2:31515得到拒绝连接。
我错过了什么吗?请帮助我解决此问题。先谢谢你了。
注意:我在“Windows 10”机器上的“Oracle VM虚拟机”中运行“Ubuntu 20”。

uemypmqf

uemypmqf1#

我解决了这个问题,改变网络类型从NAT到桥模式在虚拟框。在Oracle虚拟机中启动VM之前,请转到网络设置并将网络类型设置为桥接模式。然后启动VM,它将按预期工作。

相关问题