mysql部署mysql
时间: 2023-10-28 09:57:36 浏览: 212
安装部署MySQL数据库安装
要在Kubernetes上部署MySQL,可以按照以下步骤进行操作:
1. 创建一个MySQL配置文件(如:mysql-config.yaml),示例内容如下:
```yaml
apiVersion: v1
kind: Secret
metadata:
name: mysql-secret
type: Opaque
data:
MYSQL_ROOT_PASSWORD: <base64-encoded-root-password>
MYSQL_DATABASE: <base64-encoded-database-name>
MYSQL_USER: <base64-encoded-username>
MYSQL_PASSWORD: <base64-encoded-password>
---
apiVersion: v1
kind: Service
metadata:
name: mysql-service
spec:
selector:
app: mysql
ports:
- port: 3306
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql-deployment
spec:
selector:
matchLabels:
app: mysql
replicas: 1
template:
metadata:
labels:
app: mysql
spec:
containers:
- name: mysql
image: mysql:latest
envFrom:
- secretRef:
name: mysql-secret
ports:
- containerPort: 3306
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-persistent-storage
persistentVolumeClaim:
claimName: mysql-pvc
```
在这个配置文件中,你需要将 `<base64-encoded-root-password>`, `<base64-encoded-database-name>`, `<base64-encoded-username>`, `<base64-encoded-password>` 替换为相应的Base64编码后的值。
2. 创建一个永久存储卷声明(PersistentVolumeC
阅读全文