【问题标题】:Access Minio from outside the Kubernetes cluster从 Kubernetes 集群外部访问 Minio
【发布时间】:2021-05-07 08:53:17
【问题描述】:

我使用 new operator 在 Kubernetes 上部署了 Minio:

helm repo add minio https://operator.min.io/
helm install --namespace minio-operator --create-namespace --generate-name minio/minio-operator
kubectl apply -f https://raw.githubusercontent.com/minio/operator/master/examples/tenant-tiny.yaml
sudo -E kubefwd svc
    Port-Forward: 127.1.27.1 minio:80 to pod minio-ss-0-0:9000 
    Port-Forward: 127.1.27.2 minio-hl:9000 to pod minio-ss-0-0:9000 
    Port-Forward: 127.1.27.3 minio-ss-0-0.minio-hl:9000 to pod minio-ss-0-0:9000

租户正在工作,我可以通过 minio:80 和 minio-hl:9000 访问 Web 控制台

我想从集群外部访问存储(在 Docker 上运行的 Jupyter notebook);这是我收到错误“ConnectionRefusedError: [Errno 111] Connection denied”的地方:

def main():
    client = Minio(
        "minio:80", #minio-hl:9000 leads to the same error
        access_key="minio",
        secret_key="minio123!",
        secure=False
    )

    found = client.bucket_exists("posts")
    if not found:
        client.make_bucket("posts")
        print("Bucket 'posts' created")
    else:
        print("Bucket 'posts' already exists")

我也尝试使用带有 s3a jar 的 pyspark 来读写对象,但连接挂了很长时间,最后收到类似的错误。

有人可以帮帮我吗?非常感谢!

【问题讨论】:

    标签: python kubernetes minio


    【解决方案1】:

    希望现在提供以下信息还为时不晚:

    首先,确保您可以在端口转发后访问该服务。然后尝试使用minio python客户端做类似的事情。

    实际上,我最近也遇到了类似的问题,在再次确认端口转发后可以访问服务后,通过使用自定义 http 客户端终于解决了。

    from minio import Minio
    from minio.error import InvalidResponseError
    import urllib3
    
    def main():
        httpClient = urllib3.PoolManager(
                    cert_reqs="CERT_NONE")
    
        client = Minio('my-domain:443',
                   access_key='xxxxx',
                   secret_key='xxxxx',
                   http_client=httpClient
                  )
        try:
            objects = client.list_objects('bucket_name', prefix='/', recursive=True)
            for obj in objects:
                print(obj.bucket_name)
        except InvalidResponseError as err:
            print("error", err)
    

    【讨论】:

      猜你喜欢
      • 2021-05-16
      • 2017-12-24
      • 2021-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-28
      • 2023-03-15
      • 1970-01-01
      相关资源
      最近更新 更多