关于如何在 Kubernetes 中设置入口的 Minikube 文档不起作用

Minikube documentation on how to setup an ingress in Kubernetes doesn't work

我查了之前关于这个话题的问题:
但这并没有解决我的问题,因为该解决方案不适用于较新版本的 Kubernetes版本 1.22

# Setup minikube
minikube start
minikube addons enable ingress

# Create the Deployment and Service
kubectl create deployment web --image=gcr.io/google-samples/hello-app:1.0;
kubectl expose deployment web --type=NodePort --port=8080;

# Create the Ingress
kubectl apply -f https://k8s.io/examples/service/networking/example-ingress.yaml;

因为我在本地使用 Minikube,所以我必须在 etc/hosts 中添加来自 minikube ip 的 ip,我这样做了。


正在检查:

❯ kubectl get all
NAME                       READY   STATUS    RESTARTS   AGE
pod/web-79d88c97d6-zfhgh   1/1     Running   0          24m

NAME                 TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
service/kubernetes   ClusterIP   10.96.0.1      <none>        443/TCP          25m
service/web          NodePort    10.97.138.67   <none>        8080:31460/TCP   24m

NAME                  READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/web   1/1     1            1           24m

NAME                             DESIRED   CURRENT   READY   AGE
replicaset.apps/web-79d88c97d6   1         1         1       24m

我们有 PodServiceDeploymentRepicaSet.✅

❯ kubectl get ingress
NAME              CLASS   HOSTS              ADDRESS        PORTS   AGE
example-ingress   nginx   hello-world.info   192.168.49.2   80      24m

Ingress没问题,地址确实是MinikubeIP。 ✅

❯ cat /etc/hosts
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateHosts = false
127.0.0.1       localhost
127.0.1.1       DESKTOP-B4JM855.localdomain     DESKTOP-B4JM855

192.168.1.12    host.docker.internal
192.168.1.12    gateway.docker.internal
127.0.0.1       kubernetes.docker.internal
192.168.49.2    hello-world.info        # <----------- What we care about ✅ 

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

一切都应该是正确的,但是,我不能卷曲到 Ingress 与:

curl http://hello-world.info

我不知道是不是使用 WSL 导致了这个问题,但应该不会。

Well, I tried coupal of things but none of them worked out well with docker driver

截至目前,ingress doesn't work on docker desktop kubernetes

存在问题

所以你现在不能 运行 使用 docker Driver 进入本地。但是你可以在 AWS/IBM/GCP 云上试试这个并清除你的任务 link.

Alternatively, you can try with hyperkit driver like

minikube start --vm=true --driver=hyperkit
  • 或者 Public 云(我尝试过并且有效)将是快速完成它的不错选择。