当前位置:网站首页>云原生KubeSphere部署Mysql
云原生KubeSphere部署Mysql
2022-04-23 12:36:00 【爱上口袋的天空】
一、简介
使用KubeShere部署应用架构图:

注意三点:
- 应用的部署方式
- 应用的数据挂载(数据、配置文件)
- 应用的可访问行性
二、部署MySql的分析以及准备
1、参考我们之前使用docker部署启动mysql的脚本如下
docker run -p 3306:3306 --name mysql-01 \ -v /mydata/mysql/log:/var/log/mysql \ -v /mydata/mysql/data:/var/lib/mysql \ -v /mydata/mysql/conf:/etc/mysql/conf.d \ -e MYSQL_ROOT_PASSWORD=root \ --restart=always \ -d mysql:5.72、准备好mysql的配置文件
[client] default-character-set=utf8mb4 [mysql] default-character-set=utf8mb4 [mysqld] init_connect='SET collation_connection = utf8mb4_unicode_ci' init_connect='SET NAMES utf8mb4' character-set-server=utf8mb4 collation-server=utf8mb4_unicode_ci skip-character-set-client-handshake skip-name-resolve3、mysql部署分析
/var/lib/mysql:这个路径是容器当中mysql存储数据文件的路径,我们使用pvc将其持久化
/etc/mysql/conf.d: 这是个目录,下面有一个my.cnf配置文件,我们使用configMap将其覆盖
MYSQL_ROOT_PASSWORD:这是个环境变量,设置默认的root账户密码
三、创建ConfigMap配置mysql的my.cnf文件
1、进入配置中心->配置->创建
2、开始配置ConfigMap
![]()
ok,这样我们mysql对应的ConfigMap就创建好了
四、创建用来持久化mysql数据文件的pvc存储
1、进入存储管理->存储卷,点击创建
2、开始创建存储卷
![]()
如上,创建成功!
五、开始创建有状态的服务mysql
1、进入应用负载->工作负载->有状态副本集,点击创建
2、开始创建mysql服务
点击下一步。
点击上面的添加容器镜像,选择镜像:选择DockerHub上的mysql:5.7的镜像。
往下: 选择限制1核cpu 和 2000M 的内存以及端口的映射。
往下:
勾选 环境变量 :MYSQL_ROOT_PASSWORD密码:123456。
勾选同步主机时区。
点击√打钩并且点击下一步:
选择添加存储卷,因为我们的存储卷已经创建好了,就是那个mysql-pvc, 挂载目录:
/var/lib/mysql选择读写。
上面的是我们持久化mysql的数据文件的,下面我们再挂载配置文件:
点击挂载配置文件:
点击下一步:
点击创建:
可以点击进入查看:
可以发现已经创建成功
这里也可以查看mysql的日志和进入终端查看信息
六、通过内网访问创建好的mysql
1、首先通过终端进入mysql的内部,看一下我们的配置文件是否生效
由上可以发现,已经生效了
2、我们可以到应用负载->服务,查看我们刚创建的mysql自动生成的service服务
由上可以发现我们是无法外网访问的,只能内网容器间进行访问,因为类型是ClusterIP
可以发现在内网是可以连接上的 ,如果想要外网访问,我们需要配置service,当然一般在生产环境,内网访问就够了,因为在这个kubesphere上的容器间网络都是通的。
七、通过外网访问创建好的mysql
1、在应用负载->服务中再创建一个的mysql服务的service
![]()
创建成功,对外映射的端口是30805
2、下面通过外网的工具开始访问,
版权声明
本文为[爱上口袋的天空]所创,转载请带上原文链接,感谢
https://blog.csdn.net/K_520_W/article/details/124332030
边栏推荐
- 编程辅助工具推荐:图片工具snipaste
- Why is the premise of hash% length = = hash & (length-1) that length is the nth power of 2
- C set Logo Icon and shortcut icon
- Flash project cross domain interception and DBM database learning [Baotou cultural and creative website development]
- Qt双缓冲绘图
- 栈和队列a
- NBIOT的AT指令
- 对话PostgreSQL作者Bruce:“转行”是为了更好地前行
- 【vulnhub靶场】-dc2
- Resolve disagrees about version of symbol device_ create
猜你喜欢

网络信息安全之零信任

Introduction to metalama 4 Use fabric to manipulate items or namespaces

Worder font page font comparison table

In idea Solution to the problem of garbled code in Chinese display of properties file

IDEA设置版权信息

The database navigator uses the default MySQL connection prompt: the server time zone value 'Ö Ð¹ ú±ê ×¼ ʱ ¼ ä’ is unrecognized or repres

How to solve the computer system card?

风尚云网学习-h5的input:type属性的image属性

Qt绘制图像

Qt双缓冲绘图
随机推荐
传统企业如何应对数字化转型?这些书给你答案
MySQL函数-递归函数
Pagoda panel command line help tutorial (including resetting password)
洛谷P3236 [HNOI2014]画框 题解
Symmetric encryption, certificate encryption
[daily question] chessboard question
Buuctf Web [bjdctf2020] zjctf, but so
Plato farm - a game of farm metauniverse with Plato as the goal
Labels and paths
大家帮我看一下这是啥情况,MySQL5.5的。谢了
Why is the premise of hash% length = = hash & (length-1) that length is the nth power of 2
【Redis 系列】redis 学习十三,Redis 常问简单面试题
Basic software testing Day2 - Case Execution
S2-062 remote command execution vulnerability recurrence (cve-2021-31805)
基于卷积神经网络的遥感影像分类识别系统
万事有你 未来可期 | ONES 2022校园招聘正式开启
How do traditional enterprises cope with digital transformation? These books give you the answer
Qt一个进程运行另一个进程
How to switch PHP version in Windows 2008 system
Lesson 26 static member functions of classes










点击下一步。





















创建成功,对外映射的端口是30805