单实例mysql.yaml kubernetes

35次阅读

共计 887 个字符,预计需要花费 3 分钟才能阅读完成。

借助于容器和 k8s 管理平台,mysql 的部署和使用都很方便,能满足平时开发测试环境使用
client
集群内:
mysql -h mysql.default.svc.cluster.local -P3306 -uroot -p mysql
image
percona:5.7.22
yaml
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

正文完
 0