diff --git a/roles/setup_minio/README.md b/roles/setup_minio/README.md index e5a323bf3..d8074d26f 100644 --- a/roles/setup_minio/README.md +++ b/roles/setup_minio/README.md @@ -10,20 +10,22 @@ Role tasks: ## Variables -| Variable | Default | Required | Description | -| -------------------------------------- | ----------------------------- | ---------- | ----------------------------------------------| -| sm_minio_image | minio/minio | No | Default Minio image | -| sm_claim_size | 10Gi | No | Requested storage for Minio | -| sm_storage_class | undefined | Yes | A storage Class with Support for RWX volumes | -| sm_namespace | minio | No | Deployment Namespace | -| sm_access_key_id | minioadmin | No | Minio's Initial Username | -| sm_access_key_secret | minioadmin | No | Minio's Initial Password | -| sm_bucket_name | minio | No | Initial Bucket name | -| sm_action | install | No | Default role's action | +| Variable | Default | Required | Description | +| -------------------------------------- | ----------------------------- | ---------- | ----------------------------------------------------| +| sm_minio_image | minio/minio | No | Default Minio image | +| sm_claim_size | 10Gi | No | Requested storage for Minio | +| sm_storage_class | undefined | Yes | A storage Class with Support for RWX volumes | +| sm_namespace | minio | No | Deployment Namespace | +| sm_access_key_id | minioadmin | No | Minio's Initial Username | +| sm_access_key_secret | minioadmin | No | Minio's Initial Password | +| sm_bucket_name | minio | No | Initial Bucket name | +| sm_action | install | No | Default role's action | +| sm_service_type | NodePort | No | Type of service: NodePort, LoadBalacer or ClusterIP | ## Role requirements - A storage class with Support for ReadWriteMany volumes. NFS based providers are suitable for this. The PVC bound will fail if RWX mode is not supported. - 10Gi available in the defined StorageClass + - When enabling the service to use a external IP (`sm_service_type: LoadBalacer`) MetalLB operator is required to be installed and configured in the cluster. ## Usage example @@ -55,11 +57,32 @@ See below how to consume the services provided by Minio. ## From outside the cluster: -Get the node port assigned to the Kubernetes service. In the command shown below it is 31551 +### When using LoadBalacer service type +> NOTE: The variable `sm_service_type: LoadBalacer` is required to enable external access to the service. + +Get the external IP assigned and port to the Kubernetes service. In the command shown below is 10.20.30.40:9000 ``` $ oc get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE -minio-service LoadBalancer 172.30.108.47 9000:31551/TCP 28m +minio-service LoadBalancer 172.30.108.47 10.20.30.40 9000:31203/TCP 28m +``` + +Use the endpoint to connect: + - http://\:\ + +### When using NodePort service type (default) + +Get a node IP and the node port assigned to the Kubernetes service. In the command shown below it is 192.168.X.Y and 30521 +``` +$ oc get nodes -o custom-columns=INTERNAL-IP:status.addresses[0].address + +INTERNAL-IP +192.168.X.Y +... + +$ oc get svc +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +minio-service NodePort 172.30.251.192 9000:30521/TCP 8s ``` Use the endpoint to connect: diff --git a/roles/setup_minio/defaults/main.yml b/roles/setup_minio/defaults/main.yml index 53a7566f8..4dc944476 100644 --- a/roles/setup_minio/defaults/main.yml +++ b/roles/setup_minio/defaults/main.yml @@ -6,4 +6,5 @@ sm_access_key_secret: minioadmin sm_bucket_name: minio sm_action: install sm_minio_image: quay.io/minio/minio:latest +sm_service_type: NodePort ... diff --git a/roles/setup_minio/tasks/install.yml b/roles/setup_minio/tasks/install.yml index 6b2829957..ac82805fa 100644 --- a/roles/setup_minio/tasks/install.yml +++ b/roles/setup_minio/tasks/install.yml @@ -101,7 +101,7 @@ name: "{{ service_name }}" namespace: "{{ sm_namespace }}" spec: - type: LoadBalancer + type: "{{ sm_service_type }}" ports: - name: http port: 9000 @@ -124,51 +124,54 @@ - "node-role.kubernetes.io/worker" register: node_info -- name: Check minio service availability - vars: - random_worker_ip: "{{ node_info.resources | json_query('[].status.addresses[?type==`InternalIP`].address') | random | first }}" - node_port: "{{ service_info.resources[0].spec.ports[0].nodePort }}" - uri: - url: "http://{{ random_worker_ip }}:{{ node_port }}/minio/health/ready" - return_content: no - status_code: 200 - register: response - retries: 50 - delay: 5 - until: response.status == 200 +- name: Validate minio service using NodePort + block: + - name: Check minio service availability + vars: + random_worker_ip: "{{ node_info.resources | json_query('[].status.addresses[?type==`InternalIP`].address') | random | first }}" + node_port: "{{ service_info.resources[0].spec.ports[0].nodePort }}" + uri: + url: "http://{{ random_worker_ip }}:{{ node_port }}/minio/health/ready" + return_content: no + status_code: 200 + register: response + retries: 50 + delay: 5 + until: response.status == 200 -- name: Create working directory - tempfile: - state: directory - prefix: minio_ - register: minio_dir + - name: Create working directory + tempfile: + state: directory + prefix: minio_ + register: minio_dir -- name: Set working directory path - set_fact: - minio_dir: "{{ minio_dir.path }}" + - name: Set working directory path + set_fact: + minio_dir: "{{ minio_dir.path }}" -- name: Get Minio CLI - vars: - minio_cli: "https://dl.min.io/client/mc/release/linux-amd64/mc" - get_url: - url: "{{ minio_cli }}" - dest: "{{ minio_dir }}/" - mode: "0750" + - name: Get Minio CLI + vars: + minio_cli: "https://dl.min.io/client/mc/release/linux-amd64/mc" + get_url: + url: "{{ minio_cli }}" + dest: "{{ minio_dir }}/" + mode: "0750" -- name: Create an initial bucket - vars: - random_worker_ip: "{{ node_info.resources | json_query('[].status.addresses[?type==`InternalIP`].address') | random | first }}" - node_port: "{{ service_info.resources[0].spec.ports[0].nodePort }}" - instance: local - shell: | - {{ minio_dir }}/mc alias set {{ instance }} \ - http://{{ random_worker_ip }}:{{ node_port }} \ - {{ sm_access_key_id }} {{ sm_access_key_secret }} --api S3v4; - {{ minio_dir }}/mc mb --ignore-existing {{ instance }}/{{ sm_bucket_name }} - register: minio_cmd - retries: 18 - delay: 5 - until: minio_cmd is not failed - notify: - - "Delete temp directory" -... \ No newline at end of file + - name: Create an initial bucket + vars: + random_worker_ip: "{{ node_info.resources | json_query('[].status.addresses[?type==`InternalIP`].address') | random | first }}" + node_port: "{{ service_info.resources[0].spec.ports[0].nodePort }}" + instance: local + shell: | + {{ minio_dir }}/mc alias set {{ instance }} \ + http://{{ random_worker_ip }}:{{ node_port }} \ + {{ sm_access_key_id }} {{ sm_access_key_secret }} --api S3v4; + {{ minio_dir }}/mc mb --ignore-existing {{ instance }}/{{ sm_bucket_name }} + register: minio_cmd + retries: 18 + delay: 5 + until: minio_cmd is not failed + notify: + - "Delete temp directory" + when: sm_service_type == "NodePort" +...