借助于容器和k8s管理平台,mysql的部署和使用都很方便,能满足平时开发测试环境使用
client
集群内:
mysql -h mysql.default.svc.cluster.local -P3306 -uroot -p mysql
image
percona:5.7.22
yaml
其中PersistentVolumeClaim的storageClassName,可更改为平台支持的存储类型
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
spec:
replicas: 1
selector:
matchLabels:
name: mysql
template:
metadata:
labels:
name: mysql
spec:
containers:
- name: mysql
image: percona:5.7.22
imagePullPolicy: Always
ports:
- containerPort: 3306
resources:
limits:
memory: "500Mi"
cpu: "500m"
requests:
memory: "500Mi"
cpu: "250m"
env:
- name: MYSQL_ROOT_PASSWORD
value: "mysql"
volumeMounts:
- name: mysql-pvc
mountPath: /var/lib/mysql
volumes:
- name: mysql-pvc
persistentVolumeClaim:
claimName: mysql
---
kind: Service
apiVersion: v1
metadata:
name: mysql
spec:
type: ClusterIP
ports:
- name: mysql
port: 3306
targetPort: 3306
protocol: TCP
selector:
name: mysql
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: "5Gi"
volumeName:
storageClassName: glusterfs
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。