MicroK8s 安装使用 MinIO
2022-11-07
MinIO 是一个类 S3 的文件服务器,提供 Web 等方式管理文件。
为了简单起见,这里并没有使用官方提供的安装方法。
标准安装方式:
设置
https://minio.example.com
https://minio-console.example.com
反向代理到 minio 服务器,并且设置环境变量
MINIO_SERVER_URL=https://minio.example.com
MINIO_BROWSER_REDIRECT_URL=https://minio-console.example.com
这篇文章里并没有按照官方的要求设置成两个主机名,而是将 minio 和 minio-console 安在了一个主机名下
https://18kas.com/blob -> http://127.0.0.1:9000/lookas-blob
https://18kas.com/minio -> http://127.0.0.1:9000
https://18kas.com/minio-console/
这样安装后,需要注意的是,对 URL 签名需对 127.0.0.1:9000 进行
以下为配置文件
apiVersion: v1
kind: Secret
metadata:
name: minio-secret
type: Opaque
stringData:
MINIO_ROOT_PASSWORD: <admin-password-here>
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: minio-pvc
labels:
app: minio
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: minio
labels:
app: minio
spec:
selector:
matchLabels:
app: minio
strategy:
type: Recreate
template:
metadata:
labels:
app: minio
spec:
containers:
- name: minio
image: quay.io/minio/minio
args: ["server", "/data", "--console-address", ":9001"]
ports:
- containerPort: 9000
name: minio
- containerPort: 9001
name: minio-console
volumeMounts:
- name: minio-persistent-storage
mountPath: /data
env:
# https://github.com/minio/minio/issues/3472
# keep default 127.0.0.1:9000 and use upstream-vhost to rewrite host
# - name: MINIO_SERVER_URL
# value: "https://18kas.com/minio"
- name: MINIO_BROWSER_REDIRECT_URL
value: "https://18kas.com/minio-console/"
- name: MINIO_ROOT_USER
value: "minioadmin"
- name: MINIO_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: minio-secret
key: MINIO_ROOT_PASSWORD
volumes:
- name: minio-persistent-storage
persistentVolumeClaim:
claimName: minio-pvc
---
apiVersion: v1
kind: Service
metadata:
name: minio
labels:
app: minio
spec:
ports:
- name: minio
port: 8078
targetPort: 9000
protocol: TCP
- name: minio-console
port: 8079
targetPort: 9001
protocol: TCP
selector:
app: minio
type: ClusterIP
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: minio-ingress
annotations:
kubernetes.io/ingress.class: public
nginx.ingress.kubernetes.io/proxy-body-size: 100m
nginx.ingress.kubernetes.io/rewrite-target: /$2
nginx.ingress.kubernetes.io/upstream-vhost: 127.0.0.1:9000
spec:
tls:
- hosts:
- 18kas.com
secretName: 18kas-com-tls
rules:
- host: 18kas.com
http:
paths:
- path: /minio(/|$)(.*)
pathType: Prefix
backend:
service:
name: minio
port:
number: 8078
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: minio-console-ingress
annotations:
kubernetes.io/ingress.class: public
nginx.ingress.kubernetes.io/proxy-body-size: 100m
nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
tls:
- hosts:
- 18kas.com
secretName: 18kas-com-tls
rules:
- host: 18kas.com
http:
paths:
- path: /minio-console(/|$)(.*)
pathType: Prefix
backend:
service:
name: minio
port:
number: 8079