kubernetes部署持久化mysql5.7
1、使用以下yaml即可apiVersion: apps/v1kind: StatefulSetmetadata:labels:k8s-app: mysql1qcloud-app: mysql1name: mysql1namespace: defaultspec:replicas: 1selector:matchLabels:k8s-app: mysql1qcloud-app: mysql1ser
·
1、使用以下yaml即可
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
k8s-app: mysql1
qcloud-app: mysql1
name: mysql1
namespace: default
spec:
replicas: 1
selector:
matchLabels:
k8s-app: mysql1
qcloud-app: mysql1
serviceName: ""
template:
metadata:
labels:
k8s-app: mysql1
qcloud-app: mysql1
spec:
containers:
- env:
- name: MYSQL_ROOT_PASSWORD
value: "123456"
image: mysql:5.7
imagePullPolicy: Always
name: mysql1
resources:
limits:
cpu: 500m
memory: 1Gi
requests:
cpu: 250m
memory: 256Mi
securityContext:
privileged: false
volumeMounts:
- mountPath: /var/lib/mysql/
name: data
volumes:
- hostPath:
path: /mysql_data
name: data
---
apiVersion: v1
kind: Service
metadata:
name: mysql
namespace: default
spec:
ports:
- name: 3306-3306-tcp
nodePort: 31803
port: 3306
protocol: TCP
targetPort: 3306
selector:
k8s-app: mysql
qcloud-app: mysql
type: NodePort
更多推荐
已为社区贡献45条内容
所有评论(0)