7. 在master节点/root目录下编写YAML文件部署MySQL服务,具体要求如下: (1)Service名称:myqsl;Deployment名称:myqsl; (2)镜像:mysql:5.7; (4)挂载一个持久卷mysql-pv,拥有2GB的存储空间,路径为/ mnt/data;
时间: 2023-05-15 13:07:35 浏览: 77
k8s 创建mysql的 全套yaml文件
回答:
apiVersion: v1
kind: Service
metadata:
name: mysql
spec:
selector:
app: mysql
ports:
- name: mysql
port: 3306
targetPort: 3306
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
spec:
selector:
matchLabels:
app: mysql
replicas: 1
template:
metadata:
labels:
app: mysql
spec:
containers:
- name: mysql
image: mysql:5.7
env:
- name: MYSQL_ROOT_PASSWORD
value: "password"
ports:
- containerPort: 3306
volumeMounts:
- name: mysql-pv
mountPath: /mnt/data
volumes:
- name: mysql-pv
persistentVolumeClaim:
claimName: mysql-pvc
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
阅读全文