Access Minio from outside the Kubernetes cluster

5/7/2021

I deployed Minio on Kubernetes by using the new operator:

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

The Tenant is working and I can access the web console both at minio:80 and minio-hl:9000

I'd like to access the storage from outside the cluster (Jupyter notebook running on Docker); this is where I receive the error "ConnectionRefusedError: Errno 111 Connection refused":

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")

I also tried using pyspark with s3a jars for writing-reading objects but the connection hangs for a long time, finally receiving a similar error.

Can someone help me please? Thanks a lot!

-- SkuPak
kubernetes
minio
python

1 Answer

3/22/2022

Hope it's not too late to provide the info below:

First of all, make sure you can get access to the service after port-forward. Then try to use minio python client to do similar thing.

Actually, I have got similar issue with yours recently and finally solved by using custom http client after double confirming the service is accessible after port-forward.

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)
-- Jing DU
Source: StackOverflow