![](/img/trans.png)
[英]How to access Angular Application through Kubernetes Ingress file
[英]Access Kubernetes ingress remotely
我已經在 CentOS 7.6 的虛擬機上使用 minikube 設置了 Kubernetes 入口。 它最終在該機器上運行良好,如下所述:
Name: my-ingress
Namespace: default
Address: 172.17.0.2
Default backend: default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
Host Path Backends
---- ---- --------
localhost
/route1/?(.*) service1 (172.18.0.4:80)
/route2/?(.*) service2 (172.18.0.4:80)
Annotations: kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /$1
我使我的/etc/hosts
如下
172.17.0.2 localhost
172.17.0.2 0.0.0.0
在虛擬機上運行良好,我可以通過curl localhost/route1/api/values
成功訪問我的 API 。
但在這里我想在其他機器上訪問它進行開發。 My thought was to see the same successful result through curl 192.168.2.21/route1/api/values
on other machine, with 192.168.2.21
the IP address of the virtual machine with Kubernetes. 但它失敗了消息“來自服務器的空回復”。
有沒有其他方法可以實現這一點,訪問其他機器上的入口結果?
我嘗試的是安裝local-dev-with-docker-for-mac-kubernetes ,但沒有幫助。 並且還看到了一些其他解決服務的建議,但是因為我必須使用很多服務,擔心如果我必須避免任何端口重復,這可能很難管理。 所以我主要尋找結果解決方法Ingress。
您的配置將主機指定為 localhost,因此僅處理帶有 localhost 的傳入流量。 您可以使用同一台機器上的curl 172.17.0.2/route1/api/values
來驗證這一點。 應該得到相同的空回復消息。
要解決此問題,您可以省略主機設置,以便入口 controller 將處理所有傳入的 HTTP 流量。 https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-rules
更新
最小入口示例:
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: test-ingress
spec:
backend:
serviceName: testsvc
servicePort: 80
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.