我檢查了有關此主題的上一個問題:
Minikube with ingress example not working
但它不能解決我的問題,因為該解決方案不適用于較新版本的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,因此我必須添加來自 的 ip minikube ip,etc/hosts我這樣做了。
檢查:
? 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
我們有Pod、Service、Deployment和RepicaSet。?
? kubectl get ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
example-ingress nginx hello-world.info 192.168.49.2 80 24m
Ingress沒問題,地址確實是Minikube IP。?
? 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
一切都應該是正確的,但是,我不能卷曲到入口:
卷曲http://hello-world.info
我不知道使用 WSL 是否會導致此問題,但它不應該是。
uj5u.com熱心網友回復:
好吧,我嘗試了一些事情,但沒有一個能很好地解決
docker driver
截至目前,在docker desktop kubernetes 上,ingress存在一個問題
所以你現在不能在本地運行 ingress docker Driver。但是您可以在 AWS/IBM/GCP 云上試用此功能并清除您的任務鏈接。
或者,您可以嘗試使用
hyperkitdriverlike
minikube start --vm=true --driver=hyperkit
- 或者公共云(我嘗試過并且成功了)將是快速完成它的好選擇。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/446649.html
標籤:Kubernetes 谷歌 Kubernetes 引擎 Kubernetes入口 迷你库贝
上一篇:單個K8S部署中的多個應用程式
