无法访问kubernetes入口
我正在尝试在Azure Kubernetes上运行MLFlow服务器。将服务连接到部署时,我可以访问服务器。但是,当我尝试使用入口访问服务器时,它无法访问它。但是,当在端口80上运行Ingress公共IP时,我会发现Nginx服务器错误找不到
,这是可以预期的,但是在MLFlow Server 5000上运行时,它会超时。
以下是部署,加载平衡器服务和入口的清单文件。
部署:
apiVersion: apps/v1
kind: Deployment
metadata:
name: mlflow-deployment
labels:
app: mlflow
spec:
selector:
matchLabels:
app: mlflow
replicas: 1
template:
metadata:
labels:
app: mlflow
spec:
containers:
- name: mlflow
image: rjtshrm/mlflow:latest
args: ["--backend-store-uri", "postgresql://psql:[email protected]:5432/postgres?sslmode=require", "--default-artifact-root", "wasbs://[email protected]", "--host", "0.0.0.0"]
ports:
- containerPort: 5000
服务:负载平衡器
apiVersion: v1
kind: Service
metadata:
name: mlflow
labels:
app: mlflow
spec:
selector:
app: mlflow
type: LoadBalancer
ports:
- port: 5000
targetPort: 5000
intress:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: mlflow-server-ingress
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
ingressClassName: mlflow-server-ingress
rules:
- http:
paths:
- path: /(.*)
pathType: Prefix
backend:
service:
name: mlflow
port:
number: 5000
另外,要安装Ingress Controller,我在下面采取了步骤。
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm install ingress-nginx ingress-nginx/ingress-nginx --namespace default --set controller.service.annotations."service\.beta\.kubernetes\.io/azure-load-balancer-health-probe-request-path"=/healthz
在下面可以看到以默认名称空间运行的服务。 Ingress-nginx-controller具有公共IP,我可以在端口80上访问,并获取此错误消息404找不到
。然后,对于负载平衡器,我可以在端口5000上使用外部IP访问服务器。 在图像中可以看到
当我尝试访问Ingress Yaml文件后端口5000上的Ingress-nginx-controller无法到达该站点。 Ingress-nginx-controller的日志在这里
ps:我在部署文件。它是带有测试数据库凭证的公共图像,因此可以测试整个内容。
I am trying to run a mlflow server on Azure Kubernetes. I can access the server when attaching service to deployment as a Load Balancer. However, when I am trying to access the server using ingress it can't access it. However, when running the ingress public IP on port 80 I get Nginx server error 404 not found
, which is expected but when running on mlflow server 5000 it is timed out.
Below are the manifest files for the deployment, Load Balancer service and Ingress.
Deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
name: mlflow-deployment
labels:
app: mlflow
spec:
selector:
matchLabels:
app: mlflow
replicas: 1
template:
metadata:
labels:
app: mlflow
spec:
containers:
- name: mlflow
image: rjtshrm/mlflow:latest
args: ["--backend-store-uri", "postgresql://psql:[email protected]:5432/postgres?sslmode=require", "--default-artifact-root", "wasbs://[email protected]", "--host", "0.0.0.0"]
ports:
- containerPort: 5000
Service: Load Balancer
apiVersion: v1
kind: Service
metadata:
name: mlflow
labels:
app: mlflow
spec:
selector:
app: mlflow
type: LoadBalancer
ports:
- port: 5000
targetPort: 5000
Ingress:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: mlflow-server-ingress
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
ingressClassName: mlflow-server-ingress
rules:
- http:
paths:
- path: /(.*)
pathType: Prefix
backend:
service:
name: mlflow
port:
number: 5000
Also, to install the Ingress controller I did the steps below.
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm install ingress-nginx ingress-nginx/ingress-nginx --namespace default --set controller.service.annotations."service\.beta\.kubernetes\.io/azure-load-balancer-health-probe-request-path"=/healthz
Below it can be seen the services running in default namespace. The ingress-nginx-controller has a public IP which I can access on port 80 and get this error message 404 not found
. Then for the Load Balancer, I can access the server with external IP on port 5000.
Can be seen in the image
After applying the Ingress yaml file when I'm trying to access the ingress-nginx-controller on port 5000, the site can't be reached. the logs of ingress-nginx-controller here
PS: I have added the image and its args in the deployment file. It is public image with test Database credentials so that the whole thing can be tested.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的
.spec.ingressclassname
字段正确吗?我看到您部署了NGINX Ingress Controller。Is your
.spec.ingressClassName
field correct? I see you deployed nginx ingress controller.NGINX控制器(至少我最后一次使用它)仅在80和443上听。因此,除非您通过Helm Chart值设置Ingress Controller上的端口5000。
您 can 仍在入口后面的服务上使用端口5000 - 即,您将nginx端口80/443连接到服务的端口5000
The nginx controller (at least the last time I used it) only listens on 80 and 443. So you can't use port 5000 on the ingress controller unless you set it via the helm chart values.
You can still use port 5000 on the service behind the ingress -- i.e. you are connecting nginx port 80/443 to your service's port 5000