我已经在kubernetes集群的Pod中部署了一个mlflow版本。我可以移植到mlflow ui,现在尝试对其进行测试。为此,我在同一集群中另一个Pod上运行的Jupyter笔记本上运行以下测试。

import mlflow

print("Setting Tracking Server")
tracking_uri = "http://mlflow-tracking-server.default.svc.cluster.local:5000"

mlflow.set_tracking_uri(tracking_uri)

print("Logging Artifact")
mlflow.log_artifact('/home/test/mlflow-example-artifact.png')

print("DONE")
当我运行这个时,我得到
ConnectionError: HTTPConnectionPool(host='mlflow-tracking-server.default.svc.cluster.local', port=5000): Max retries exceeded with url: /api/2.0/mlflow/runs/get? (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object>: Failed to establish a new connection: [Errno 111] Connection refused'))
yaml和docker中显示了我部署mlflow pod的方式:
Yaml:
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mlflow-tracking-server
  namespace: default
spec:
  selector:
    matchLabels:
      app: mlflow-tracking-server
  replicas: 1
  template:
    metadata:
      labels:
        app: mlflow-tracking-server
    spec:
      containers:
      - name: mlflow-tracking-server
        image: <ECR_IMAGE>
        ports:
        - containerPort: 5000
        env:
        - name: AWS_MLFLOW_BUCKET
          value: <S3_BUCKET>
        - name: AWS_ACCESS_KEY_ID
          valueFrom:
            secretKeyRef:
              name: aws-secret
              key: AWS_ACCESS_KEY_ID
        - name: AWS_SECRET_ACCESS_KEY
          valueFrom:
            secretKeyRef:
              name: aws-secret
              key: AWS_SECRET_ACCESS_KEY

---
apiVersion: v1
kind: Service
metadata:
  name: mlflow-tracking-server
  namespace: default
  labels:
    app: mlflow-tracking-server
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-type: nlb
spec:
  externalTrafficPolicy: Local
  type: LoadBalancer
  selector:
    app: mlflow-tracking-server
  ports:
    - name: http
      port: 5000
      targetPort: http
当dockerfile调用执行mlflow server命令的脚本:mlflow server --default-artifact-root ${AWS_MLFLOW_BUCKET} --host 0.0.0.0 --port 5000时,我无法连接到使用该mlflow pod创建的服务。
我已经尝试使用跟踪uri http://mlflow-tracking-server.default.svc.cluster.local:5000,我已经尝试使用服务EXTERNAL-IP:5000,但是我尝试的所有内容都无法使用该服务进行连接和登录。将mlflow服务器Pod部署到kubernetes集群时,我缺少任何东西吗?

最佳答案

您的 mlflow-tracking-server 服务应具有ClusterIP类型,而不是LoadBalancer。

两个Pod都在同一个Kubernetes集群中,因此没有理由使用LoadBalancer Service类型。

关于kubernetes - Kubernetes MLflow服务Pod连接,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/61351024/

10-09 17:53