2022-02-07:k8s安装mysql,yaml如何写?(非面试题)
2022-02-07:k8s安装mysql,yaml如何写?(非面试题)答案2022-02-07:yaml如下:apiVersion: apps/v1kind: Deploymentmetadata:labels:app: mysqlname: mysqlnamespace: moonfddspec:replicas: 1selector:matchLabels:app: mysqltemplat
·
2022-02-07:k8s安装mysql,yaml如何写?(非面试题)
答案2022-02-07:
yaml如下:
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: mysql
name: mysql
namespace: moonfdd
spec:
replicas: 1
selector:
matchLabels:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
containers:
- env:
- name: MYSQL_ROOT_PASSWORD
value: 'moonfdd'
image: 'mysql:8.0'
name: mysql
volumeMounts:
- mountPath: /var/lib/mysql
name: volv
volumes:
- hostPath:
path: /root/k8s/moonfdd/mysql/var/lib/mysql
type: DirectoryOrCreate
name: volv
---
apiVersion: v1
kind: Service
metadata:
labels:
app: mysql
name: mysql
namespace: moonfdd
spec:
ports:
- port: 3306
protocol: TCP
targetPort: 3306
selector:
app: mysql
type: NodePort
结果如下:
更多推荐
已为社区贡献26条内容
所有评论(0)