我正在使用 VB 在我的 Mac 上运行 minikube。我能够使用声明性方法在 minikube 上启动数据库。但是当我删除部署时,数据就会丢失。现在我的问题是——
- 所有这些数据都保存在哪里?
- 如何更改配置以便将数据保存在主机上(我的意思是 mac)?这样删除或重新启动 pod/deployment 不会删除所有数据。
这是我的 yaml 文件-
apiVersion: v1
kind: Service
metadata:
name: track-mysql
labels:
app: track
spec:
ports:
- port: 3306
selector:
app: track
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: mysql-pv
labels:
type: local
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /data/pv001
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pvc
labels:
app: track
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: track-mysql
labels:
app: track
spec:
selector:
matchLabels:
app: track
strategy:
type: Recreate
template:
metadata:
labels:
app: track
spec:
containers:
- image: mysql:5.6
name: mysql
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql
key: password
- name: MYSQL_DATABASE
value: track
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-persistent-storage
persistentVolumeClaim:
claimName: mysql-pvc
我已经检查了,在我的mac上,数据不在/data/pv001