How do I expose MinIO Service on Kubernetes with an Ingress?
In this guide, we will deploy MinIO, a high-performance object storage server, on a Kubernetes cluster and expose it using an Ingress resource. This will allow external access to the MinIO service.
Key Points:
- Deploy a MinIO service on Kubernetes.
- Create a Kubernetes Ingress resource to expose the MinIO service.
- Use Pulumi to manage the infrastructure as code.
import * as pulumi from "@pulumi/pulumi";
import * as k8s from "@pulumi/kubernetes";
// Create a Kubernetes Namespace for MinIO
const ns = new k8s.core.v1.Namespace("minio-ns", {
metadata: { name: "minio" }
});
// Deploy the MinIO Deployment
const minioDeployment = new k8s.apps.v1.Deployment("minio-deployment", {
metadata: {
namespace: ns.metadata.name,
name: "minio"
},
spec: {
selector: { matchLabels: { app: "minio" } },
replicas: 1,
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" }
],
volumeMounts: [{
name: "data",
mountPath: "/data"
}]
}],
volumes: [{
name: "data",
emptyDir: {}
}]
}
}
}
});
// Create a MinIO Service
const minioService = new k8s.core.v1.Service("minio-service", {
metadata: {
namespace: ns.metadata.name,
name: "minio"
},
spec: {
selector: { app: "minio" },
ports: [{
port: 9000,
targetPort: 9000
}]
}
});
// Create an Ingress Resource to expose MinIO
const minioIngress = new k8s.networking.v1.Ingress("minio-ingress", {
metadata: {
namespace: ns.metadata.name,
name: "minio-ingress",
annotations: {
"nginx.ingress.kubernetes.io/rewrite-target": "/"
}
},
spec: {
rules: [{
host: "minio.example.com",
http: {
paths: [{
path: "/",
pathType: "Prefix",
backend: {
service: {
name: minioService.metadata.name,
port: { number: 9000 }
}
}
}]
}
}]
}
});
export const ingressUrl = pulumi.interpolate`http://${minioIngress.metadata.name}.${ns.metadata.name}.svc.cluster.local`;
Summary:
In this guide, we deployed a MinIO service on a Kubernetes cluster and exposed it using an Ingress resource. We used Pulumi to manage the Kubernetes resources, including the Namespace, Deployment, Service, and Ingress. The Ingress resource allows external access to the MinIO service, making it accessible via a specified hostname.
Deploy this code
Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.
Sign upNew to Pulumi?
Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.
Sign upThank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.