1. 쿠버네티스를 통해 MinIO 설치

$ vi minio_install.yml
apiVersion: v1
kind: Namespace
metadata:
  name: minio
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: minio-local-persistent-volume
  namespace: minio
spec:
  capacity:
    storage: 6.9T
  accessModes:
  - ReadWriteMany
  volumeMode: Filesystem
  storageClassName: "minio-local-storage"
  local:
    path: /data
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - "Minio설치IP"

  claimRef:
    namespace: minio
    name: minio-local-persistent-volume-claim
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: minio-local-persistent-volume-claim
  namespace: minio
spec:
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: 6.9T
  storageClassName: minio-local-storage
  volumeMode: Filesystem
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: minio-deployment
  namespace: minio
spec:
  selector:
    matchLabels:
      app: minio
  strategy:
    type: Recreate
  replicas: 1
  template:
    metadata:
      labels:
        app: minio
    spec:
      volumes:
      - name: data
        persistentVolumeClaim:
          claimName: minio-local-persistent-volume-claim
      containers:
      - name: minio
        image: minio/minio:latest
        args:
        - "server"
        - "--address=:9000"
        - "--console-address=:9001"
        - "/data"
        env:
        - name: MINIO_ACCESS_KEY
          value: "minio"
        - name: MINIO_SECRET_KEY
          value: "melovethanos"
        ports:
        - name: service
          containerPort: 9000
        - name: console
          containerPort: 9001
        volumeMounts:
        - name: data
          mountPath: /data
---
apiVersion: v1
kind: Service
metadata:
  name: minio-service-headless
  namespace: minio
spec:
  selector:
    app: minio
  ports:
  - name: service
    port: 9000
    targetPort: 9000
    protocol: TCP
  - name: console
    port: 9001
    targetPort: 9001
    protocol: TCP
  type: ClusterIP
  clusterIP: None
---
apiVersion: v1
kind: Service
metadata:
  name: minio-loadbalancer-service
  namespace: minio
spec:
  selector:
    app: minio
  ports:
  - name: service
    port: 9000
    targetPort: 9000
    protocol: TCP
  - name: console
    port: 9001
    targetPort: 9001
    protocol: TCP
  type: LoadBalancer



2. MinIO 생성 및 MinIO 생성 확인

# MinIO생성
$ kubectl apply -f minio_install.yml
namespace/minio created
persistentvolume/minio-local-persistent-volume created
persistentvolumeclaim/minio-local-persistent-volume-claim created
deployment.apps/minio-deployment created
service/minio-service-headless created
service/minio-loadbalancer-service created

# 생성 확인 → 내용이 많아 생략함
$ kubectl get -n minio all -o wide

# PV 생성 확인
$ kubectl get -n minio persistentvolume
NAME                                       CAPACITY  ACCESS MODES       RECLAIM POLICY   STATUS CLAIM            STORAGECLASS                                     REASON                       AGE
minio-local-persistent-volume     6900G          RWX                        Retain                  Bound    minio/minio-local-persistent-volume-claim       minio-local-storage              92s

# PVC 생성 확인
$ kubectl get -n minio persistentvolumeclaims
NAME                                              STATUS                   VOLUME                 CAPACITY   ACCESS MODES          STORAGECLASS              AGE
minio-local-persistent-volume-claim   Bound    minio-local-persistent-volume   6900G            RWX                  minio-local-storage          117s



3. headless 서비스 nslookup 확인

$ nslookup minio-service-headless.minio.svc.cluster.local
Server:         210.220.163.82
Address:        210.220.163.82#53

Non-authoritative answer:
Name:   minio-service-headless.minio.svc.cluster.local
Address: 218.38.137.27



4. MinIO 서비스의 Service IP를 통해 생성 확인 → Access Denied로 접근 불가

  • minio에 curl로 접근하면 Access Denied됨으로 다른 방법으로 접근

    # clusterIP 서비스를 통해 접근 가능
    $ curl 20.10.118.211:9000
    <?xml version="1.0" encoding="UTF-8"?>
    <Error><Code>AccessDenied</Code><Message>Access Denied.</Message><Resource>/</Resource><RequestId>16E0270B55D8E06A</RequestId><HostId>c2659a6e-1046-4fd9-8793-e756fbc033a2</HostId></Error>
    
    # LoadBalancer 할당 IP 서비스를 통해 접근 가능
    $ curl [LoadBalancer IP]:9000
    <?xml version="1.0" encoding="UTF-8"?>
    <Error><Code>AccessDenied</Code><Message>Access Denied.</Message><Resource>/</Resource><RequestId>16E026EBFCC13E44</RequestId><HostId>c2659a6e-1046-4fd9-8793-e756fbc033a2</HostId></Error>



5. MinIO 서비스에 Python으로 접근하여 확인

  • curl로 접근할 수 없기에 MinIO Client로 접근

    # minio 테스트에 사용할 파이썬3과 minio 패키지 설치
    $ yum install -y python3
    $ pip3 install minio
    
    # minio 접속 가능 테스트
    $ vi minio_api.py
    #!/bin/python3
    from minio import Minio
    
    if __name__ == '__main__':
       minioIP = "20.10.180.199:9000"     # serviceIP
       minioAccessKey = "minio"
       minioSecretKey = "melovethanos"
       client = Minio(minioIP, minioAccessKey, minioSecretKey, secure=False)
       print(client)
    
    # minio 접속 가능 테스트 실행 -> Minio Object 출력 시 이상 없음
    $ python3 minio_api.py
    <minio.api.Minio object at 0x7f2740e873c8>

+ Recent posts