我正在尝试将流量路由到 Kubernetes 集群中托管的应用程序。目前,我正在使用 Ngroks 免费域名。例如 happy-frog-dancing.ngrok-free.app。
我已经设置了这个 ingress-depl
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ngrok-ingress-depl
namespace: theblock
annotations:
kubernetes.io/ingress.class: ngrok
spec:
ingressClassName: ngrok
rules:
- host: dominant-hawk-factual.ngrok-free.app
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: app-service
port:
number: 8000
- host: server.dominant-hawk-factual.ngrok-free.app
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: server-service
port:
number: 3000
我收到无效错误
{"level":"info","ts":"2024-07-14T14:47:56Z","logger":"controllers.ingress","msg":"Ingress is not valid so skipping it","ingress":{"name":"ngrok-ingress-depl","namespace":"theblock"}}
但是当我做这样的事情时效果很好。
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ngrok-ingress-depl
namespace: theblock
annotations:
kubernetes.io/ingress.class: ngrok
spec:
ingressClassName: ngrok
rules:
- host: dominant-hawk-factual.ngrok-free.app
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: app-service
port:
number: 8000
# - host: dominant-hawk-factual.ngrok-free.app
# http:
# paths:
- path: /server
pathType: Prefix
backend:
service:
name: server-service
port:
number: 3000
尝试做这样的事情时,最佳实践是什么?
我尝试在 Ngrok 仪表板中创建选择器,但我不熟悉或不熟悉这些系统的工作原理。
感谢您使用 ngrok 并提出问题。免费帐户仅支持一个静态域,其中包括添加前缀。要使用多个静态域(包括添加前缀),您需要使用付费帐户。您可以在 ngrok 的定价页面 上找到这些选项。希望有帮助!