写一个k8smysql.yaml
时间: 2023-03-15 22:25:55 浏览: 167
k8s 创建mysql的 全套yaml文件
apiVersion: apps/v1
kind: Deployment
metadata:
name: k8s-mysql
spec:
selector:
matchLabels:
app: k8s-mysql
replicas: 1
template:
metadata:
labels:
app: k8s-mysql
spec:
containers:
- name: k8s-mysql
image: mysql:5.7
ports:
- containerPort: 3306
env:
- name: MYSQL_ROOT_PASSWORD
value: my-secret-pw
- name: MYSQL_DATABASE
value: db_name
- name: MYSQL_USER
value: user_name
- name: MYSQL_PASSWORD
value: pass_word
volumeMounts:
- name: k8s-mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: k8s-mysql-persistent-storage
persistentVolumeClaim:
claimName: k8s-mysql-pv-claim
阅读全文