利用k8s安装mysql
2022/2/23 2:23:49
本文主要是介绍利用k8s安装mysql,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1.在以下网页中搜索mysql
kubebiz官方地址
2.直接在仪表盘中创建mysql
1).选择msyql版本和k8s版本(一般选择最新)
2).将yaml文件修改
apiVersion: "apps/v1" kind: Deployment metadata: name: my-mysql namespace: default labels: app: my-mysql spec: replicas: 1 selector: matchLabels: app: my-mysql template: metadata: labels: app: my-mysql spec: volumes: - name: data hostPath: path: nfs/k8s/hfocean-iot/mysql containers: - env: - name: MYSQL_ROOT_PASSWORD value: 123456 - name: MYSQL_USER value: test - name: MYSQL_PASSWORD value: 123456 image: 'mysql:5.7.33' imagePullPolicy: IfNotPresent name: my-mysql ports: - containerPort: 3306 protocol: TCP name: http volumeMounts: - name: my-mysql-data mountPath: /var/lib/mysql - name: mysql-conf mountPath: /etc/mysql/mysql.conf.d
以下是我公司内部实际应用的json配置(关键部分已修改)(下面这个和上面的配置都可以运行)
{ "apiVersion": "apps/v1", "kind": "Deployment", "metadata": { "name": "mysql-test", "namespace": "命名空间", "labels": { "env": "test", "name": "mysql" } }, "spec": { "replicas": 1, "selector": { "matchLabels": { "env": "test", "name": "mysql" } }, "template": { "metadata": { "name": "mysql", "labels": { "env": "test", "name": "mysql" } }, "spec": { "containers": [ { "name": "mysql", "image": "mysql:5.7", "env": [ { "name": "MYSQL_ROOT_PASSWORD", "value": "123456" } ], "volumeMounts": [ { "name": "data", "mountPath": "/var/lib/mysql" } ] } ], "volumes":[ { "name": "data", "hostPath": { "path": "/nfs/k8s/hfocean-iot/duixia/mysql" } } ] } } } }
3).将文件复制到仪表盘
3.通过命令创建mysql
1).选择msyql版本和k8s版本(一般选择最新),复制命令
3).执行命令
kubectl apply -f https://www.kubebiz.com/raw/KubeBiz/mysql/5.7.33/Deployment.yaml
这篇关于利用k8s安装mysql的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-20MySQL集群部署教程:入门级详解
- 2024-11-20MySQL集群教程:入门与实践指南
- 2024-11-20部署MySQL集群教程:新手入门指南
- 2024-11-20MySQL读写分离教程:轻松入门
- 2024-11-20部署MySQL集群入门:一步一步搭建你的数据库集群
- 2024-11-19部署MySQL集群学习:入门教程
- 2024-11-19如何部署MySQL集群:新手入门教程
- 2024-11-19Mysql安装教程:新手必看的详细安装指南
- 2024-11-18Mysql安装入门:新手必读指南
- 2024-11-18MySQL事务MVCC原理入门详解