gpt4 book ai didi

kubernetes - 官方 kubernetes 教程中的 Ingress 无法正常工作

转载 作者:行者123 更新时间:2023-12-02 18:24:51 25 4
gpt4 key购买 nike

我正在关注this official k8 ingress tutorial 。但是我无法curl minikube IP 地址并访问“web”应用程序。

minikube addons enable ingress
kubectl create deployment web --image=gcr.io/google-samples/hello-app:1.0
kubectl expose deployment web --type=NodePort --port=8080
kubectl apply -f https://k8s.io/examples/service/networking/example-ingress.yaml

我能够 curl minikube service web --url 的结果

    curl http://127.0.0.1:64671 
Hello, world!
Version: 1.0.0
Hostname: web-79d88c97d6-8z8tc

但不是通过入口,使用 kubectl apply -f https://k8s.io/examples/service/networking/example-ingress.yaml

(我没有外部 IP - 只有“localhost”。)

NGG282 kubernetes-ingress % kubectl get ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
example-ingress nginx * localhost 80 66m

这对于 minikube 来说似乎是正常的。尝试 curl minikube IP:

curl $(minikube ip)
curl: (7) Failed to connect to 192.168.49.2 port 80: Operation timed out

有什么帮助吗?

----------编辑:

kubectl get deploy -n ingress-nginx -o yaml

ports:
- containerPort: 80
hostPort: 80
name: http
protocol: TCP
- containerPort: 443
hostPort: 443
name: https
protocol: TCP
- containerPort: 8443
name: webhook
protocol: TCP

kubectl get svc -n ingress-nginx -o yaml
apiVersion: v1
items:
- apiVersion: v1
kind: Service
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app.kubernetes.io/component":"controller","app.kubernetes.io/instance":"ingress-nginx","app.kubernetes.io/name":"ingress-nginx"},"name":"ingress-nginx-controller","namespace":"ingress-nginx"},"spec":{"ipFamilies":["IPv4"],"ipFamilyPolicy":"SingleStack","ports":[{"appProtocol":"http","name":"http","port":80,"protocol":"TCP","targetPort":"http"},{"appProtocol":"https","name":"https","port":443,"protocol":"TCP","targetPort":"https"}],"selector":{"app.kubernetes.io/component":"controller","app.kubernetes.io/instance":"ingress-nginx","app.kubernetes.io/name":"ingress-nginx"},"type":"NodePort"}}
creationTimestamp: "2021-12-16T11:41:35Z"
labels:
app.kubernetes.io/component: controller
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/name: ingress-nginx
name: ingress-nginx-controller
namespace: ingress-nginx
resourceVersion: "489"
uid: 63826bc2-5d90-42f1-861f-f7f082ccf0fb
spec:
clusterIP: 10.104.208.171
clusterIPs:
- 10.104.208.171
externalTrafficPolicy: Cluster
internalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- appProtocol: http
name: http
nodePort: 30783
port: 80
protocol: TCP
targetPort: http
- appProtocol: https
name: https
nodePort: 30860
port: 443
protocol: TCP
targetPort: https
selector:
app.kubernetes.io/component: controller
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/name: ingress-nginx
sessionAffinity: None
type: NodePort
status:
loadBalancer: {}
- apiVersion: v1
kind: Service
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app.kubernetes.io/component":"controller","app.kubernetes.io/instance":"ingress-nginx","app.kubernetes.io/name":"ingress-nginx"},"name":"ingress-nginx-controller-admission","namespace":"ingress-nginx"},"spec":{"ports":[{"appProtocol":"https","name":"https-webhook","port":443,"targetPort":"webhook"}],"selector":{"app.kubernetes.io/component":"controller","app.kubernetes.io/instance":"ingress-nginx","app.kubernetes.io/name":"ingress-nginx"},"type":"ClusterIP"}}
creationTimestamp: "2021-12-16T11:41:35Z"
labels:
app.kubernetes.io/component: controller
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/name: ingress-nginx
name: ingress-nginx-controller-admission
namespace: ingress-nginx
resourceVersion: "483"
uid: fe797532-27c9-4dd1-a1bc-0662a3d2a4da
spec:
clusterIP: 10.106.175.35
clusterIPs:
- 10.106.175.35
internalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- appProtocol: https
name: https-webhook
port: 443
protocol: TCP
targetPort: webhook
selector:
app.kubernetes.io/component: controller
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/name: ingress-nginx
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
kind: List
metadata:
resourceVersion: ""
selfLink: ""

最佳答案

好吧,显然这是一个 known issue with minikube , Ingress 仅在 Linux 上正常工作。

The ingress, and ingress-dns addons are currently only supported onLinux. See #7332

您需要在 Windows/macOS 上建立 minikube 隧道,然后才能 curl,但仍然存在差异:

Windows 上,127.0.0.1localhost 都重定向到应用程序。在 ma​​cOS 上,127.0.0.1localhost 显示“nginX not found”消息,但 curl hello-world.info 仅在更改 etc/hosts 后才有效。

关于kubernetes - 官方 kubernetes 教程中的 Ingress 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70366074/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com