我在 Ubuntu 桌面上的 Kubernetes 上部署了 Minio。它工作正常,除了每当我重新启动机器时,存储在 Minio 中的所有内容都会神秘地消失(如果我创建几个包含文件的存储桶,我会在重新启动后回到完全空白的石板 - 存储桶及其所有文件完全消失(。
当我设置 Minio 时,我在 Kubernetes 中创建了一个持久卷,该卷挂载到一个文件夹(/mnt/minio/minio
- 我在/mnt/minio
上挂载了一个 4 TB 的 HDD,里面有一个名为minio
的文件夹(。我注意到即使我在 Minio 中存储内容,这个文件夹似乎也是空的,所以也许 Minio 忽略了持久卷并使用容器存储?但是,我不知道为什么会发生这种情况;我同时拥有 PV 和 PV 声明,kubectl 表明它们相互绑定。
以下是我申请部署minio安装的yaml文件:
kind: PersistentVolume
apiVersion: v1
metadata:
name: minio-pv-volume
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 100Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/minio/minio"
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: minio-pv-claim
labels:
app: minio-storage-claim
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 99Gi
apiVersion: apps/v1 # for k8s versions before 1.9.0 use apps/v1beta2 and before 1.8.0 use extensions/v1beta1
kind: Deployment
metadata:
# This name uniquely identifies the Deployment
name: minio-deployment
spec:
selector:
matchLabels:
app: minio
strategy:
type: Recreate
template:
metadata:
labels:
# Label is used as selector in the service.
app: minio
spec:
# Refer to the PVC created earlier
volumes:
- name: storage
persistentVolumeClaim:
# Name of the PVC created earlier
claimName: minio-pv-claim
containers:
- name: minio
# Pulls the default Minio image from Docker Hub
image: minio/minio:latest
args:
- server
- /storage
env:
# Minio access key and secret key
- name: MINIO_ACCESS_KEY
value: "minio"
- name: MINIO_SECRET_KEY
value: "minio123"
ports:
- containerPort: 9000
hostPort: 9000
# Mount the volume into the pod
volumeMounts:
- name: storage # must match the volume name, above
mountPath: "/mnt/minio/minio"
apiVersion: v1
kind: Service
metadata:
name: minio-service
spec:
type: LoadBalancer
ports:
- port: 9000
targetPort: 9000
protocol: TCP
selector:
app: minio
你需要在容器/mnt/minio/minio/上挂载的目录中挂载容器的/storage目录;
args:
- server
- /mnt/minio/minio/storage
但请考虑使用 StatefulSet 进行部署,以便在容器重新启动时,它将保留上一个容器的所有内容。