deploying a minio service to kubernetes
Tags: kubernetes, minio
Published: 2024-04-08 21:50:51

Here are the basic steps to getting a [minio ](https://min.io/) tenant deployed inot kubernetes. There are some pre-requisites tasks to be deployed (and will not be covered in this article) including
- [cert-manager](https://cert-manager.io/)
- [ingress-nginx](https://github.com/kubernetes/ingress-nginx)
- [helm](https://helm.sh/)

## Add Helm Respository

Lets start by installing the helm repository

```console
helm repo add minio-operator https://operator.min.io
helm repo update
```

## Create the minio operator

Now lets create the minio operator that we will use later to create the tenant. 

Create a file `minio-operator.yaml`

```yaml
console:
  ingress:
    enabled: true
    ingressClassName: "nginx"
    annotations:
      cert-manager.io/cluster-issuer: vault-issuer
    tls:
    - hosts:
      - ui-operator-7f000101.nip.io
      secretName: minio-console-tls
    host: ui-operator-7f000101.nip.io
    path: /
    pathType: Prefix
    number: 9090
```
and deploy it using
```console
helm upgrade --install operator minio-operator/operator --namespace minio-operator --create-namespace -f minio-operator.yaml
```

Confirm it is running by checking the output of `kubectl get pods -n minio-operator` which should be similair to

```console
NAME                              READY   STATUS    RESTARTS   AGE                                          
console-7fcfdb8d98-8kwxd          1/1     Running   0          137m                                         
minio-operator-69986bb674-8qdg6   1/1     Running   0          137m                                         
minio-operator-69986bb674-pz8rc   1/1     Running   0          137m
```

we can get the `jwt` required to access the console by using the following command.

```console
kubectl get secret/console-sa-secret -n minio-operator -o go-template='{{.data.token | base64decode}}' 
```

Open a web browser to [ui-operator-7f000101.nip.io](cui-operator-7f000101.nip.io) and use the `jwt` collected before.

Congrats the minio operator has been deployed and lets create a tenant.

## Add a tenant

Create a file `minio-tenant.yaml`

```yaml

secrets:
  name: fido-env-configuration
  accessKey: admin
  secretKey: passw0rd
tenant:
  name: fido
  configuration:
    name: fido-env-configuration
  pools: 
    - servers: 1
      name: pool
      size: 200Mi
      volumesPerServer: 1
ingress:
  api:
    enabled: true
    ingressClassName: "nginx"
    annotations:
      cert-manager.io/cluster-issuer: vault-issuer
      nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
    tls:
    - hosts:
      - api-fido-7f000101.nip.io
      secretName: fido-minio-api-tls
    host: api-fido-7f000101.nip.io
    path: /
    pathType: Prefix
  console:
    enabled: true
    ingressClassName: "nginx"
    annotations:
      cert-manager.io/cluster-issuer: vault-issuer
      nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
    tls:
    - hosts:
      - ui-fido-7f000101.nip.io
      secretName: fido-minio-console-tls
    host: ui-fido-7f000101.nip.io
    path: /
    pathType: Prefix
```
and deploy it using
```console
helm upgrade --install --namespace minio-fido --create-namespace minio-fido minio-operator/tenant -f minio-tenant.yaml
```
confirm it is running using `kubectl get pods -n minio-fido` which should be similair to

```console
NAME          READY   STATUS    RESTARTS   AGE
fido-pool-0   2/2     Running   0          68m
```

Open a web browser to [ui-fido-7f000101.nip.io](cui-fido-7f000101.nip.io) and use the credentials `admin:password` defined in the secret `fido-env-configuration`.

Congrats the minio tenant has been deployed and so lets configure the `mc` command.

## mc configuration

Download the `mc` from the instructions here <https://min.io/docs/minio/linux/reference/minio-mc.html#install-mc>

open a command prompt / terminal and issue the following

```console
mc alias set fido/ https://api-fido-7f000101.nip.io admin password
```

create a bucket and copy a test file to it

1. Create a bucket

   ```console
   mc mb fido/backups
   ```

   returns

   ```console
   Bucket created successfully `fido/backups`. 
   ```

2. Copy a file to it

   ```console
   # linux/mac touch test
   # windows powershell echo $null >> filename
   mc cp test fido/backups
   ```

   returns

   ```console
   0 B / ? [  =] 
   ```

3. list contents of the bucket

   ```console
   mc ls fido/backups
   ```

   returns

   ```console
   [2024-04-09 08:07:58 AEST]     0B STANDARD test     
   ```
When completed check the operator and bucket ui to see similar to

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vfe5niy1q4bvcmlbqp1k.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f7wxcbu9134igkip21hd.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/du6qz46t2vxnzz0gnff3.png)