1. Answers
  2. Configuring Kubernetes Storage with Minio

How do I configure Kubernetes storage with Minio?

Here, we will configure Kubernetes storage using Minio as the backend. Minio is a high-performance, distributed object storage system. We’ll create a StorageClass in Kubernetes that uses Minio. This example assumes you already have a Minio instance running in your cluster.

Below is a step-by-step process to set this up:

import * as pulumi from "@pulumi/pulumi";
import * as kubernetes from "@pulumi/kubernetes";

// Define the Minio Service
const minio = new kubernetes.core.v1.Service("minio", {
    metadata: {
        name: "minio",
        namespace: "default",
    },
    spec: {
        selector: {
            app: "minio",
        },
        ports: [{
            port: 9000,
            targetPort: 9000,
        }],
    },
});
// Define the Minio Deployment
const minioDeployment = new kubernetes.apps.v1.Deployment("minio", {
    metadata: {
        name: "minio",
        namespace: "default",
        labels: {
            app: "minio",
        },
    },
    spec: {
        replicas: 1,
        selector: {
            matchLabels: {
                app: "minio",
            },
        },
        template: {
            metadata: {
                labels: {
                    app: "minio",
                },
            },
            spec: {
                containers: [{
                    name: "minio",
                    image: "minio/minio:latest",
                    args: [
                        "server",
                        "/data",
                    ],
                    ports: [{
                        containerPort: 9000,
                    }],
                    env: [
                        {
                            name: "MINIO_ACCESS_KEY",
                            value: "minioadmin",
                        },
                        {
                            name: "MINIO_SECRET_KEY",
                            value: "minioadmin",
                        },
                    ],
                }],
            },
        },
    },
});
// Define the StorageClass
const minioStorageClass = new kubernetes.storage.v1.StorageClass("minio", {
    metadata: {
        name: "minio-storage-class",
    },
    provisioner: "minio.min.io/bucket",
    parameters: {
        bucket: "k8s-storage",
        region: "us-east-1",
        endpoint: "http://minio.default.svc.cluster.local:9000",
        accessKey: "minioadmin",
        secretKey: "minioadmin",
        secure: "false",
    },
    reclaimPolicy: "Delete",
});
export const serviceName = minio.metadata.apply(metadata => metadata.name);
export const storageClassName = minioStorageClass.metadata.apply(metadata => metadata.name);

In this example, we’ve defined the necessary Kubernetes resources:

  1. Provider Configuration: Points to the Kubernetes cluster configuration.
  2. Minio Service: Exposes the Minio deployment within the cluster.
  3. Minio Deployment: Runs the Minio instance in the cluster.
  4. StorageClass: Custom StorageClass that specifies Minio as the provisioner.
  5. Outputs: Outputs the Minio service name and StorageClass name to be used elsewhere in your applications.

This setup allows Kubernetes to interact with Minio for provisioning storage resources dynamically.

Deploy this code

Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.

Sign up

New to Pulumi?

Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.

Sign up