kuboard.cn
This commit is contained in:
@ -23,7 +23,7 @@
|
||||
|
||||
Spring Cloud on Kubernetes 并不对 Spring Cloud 架构、组件等做过多解释,而是将重点放在如何将 Spring Cloud 的各类型组件顺利部署到 Kubernetes 环境中。
|
||||
|
||||
为了更好地阐述此主题,作者准备了一个最简单的微服务 example 作为例子,该 example 只实现了对一张简单数据库表执行 CRUD 操作的功能,该 example 的部署架构如下图所示,源代码请参考 [kuboard-example](https://github.com/eip-work/kuboard-example),您也可以直接通过 Kuboard [导入 example 微服务](/guide/example/import.html) 完成该 example 的部署
|
||||
为了更好地阐述此主题,作者准备了一个最简单的微服务 example 作为例子,该 example 只实现了对一张简单数据库表执行 CRUD 操作的功能,该 example 的部署架构如下图所示,源代码请参考 [kuboard-example](https://github.com/eip-work/kuboard-example),您也可以直接通过 Kuboard [导入 example 微服务](/guide/example/import.html)
|
||||
|
||||

|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# 部署 cloud-eureka
|
||||
|
||||
|
||||
本文所使用的代码请参考 [cloud-eureka](https://github.com/eip-work/kuboard-example/tree/master/cloud-eureka)
|
||||
|
||||
## 检查 cloud-eureka 项目的配置
|
||||
|
||||
@ -107,7 +107,7 @@ java -jar /eip-work/app.jar
|
||||
|
||||
**访问方式及互联网入口**
|
||||
|
||||
Eureka 运行在 9200 端口。Spring Cloud 的微服务通过 CLOUD_EUREKA_DEFAULT_ZONE 中的配置直接与 Eureka 服务通信。
|
||||
Eureka 运行在 9200 端口。Spring Cloud 的微服务组件通过 CLOUD_EUREKA_DEFAULT_ZONE 中的配置直接与 Eureka 容器组通信。
|
||||
|
||||
是否配置访问方式及互联网入口?
|
||||
|
||||
|
||||
77
micro-service/spring-cloud/db-example.md
Normal file
77
micro-service/spring-cloud/db-example.md
Normal file
@ -0,0 +1,77 @@
|
||||
# 部署 db-example
|
||||
|
||||
本文所使用的代码请参考 [db-example](https://github.com/eip-work/kuboard-example/tree/master/db-example)
|
||||
|
||||
## 检查 db-example 项目的配置
|
||||
|
||||
**项目结构解读**
|
||||
|
||||
|
||||
|
||||
**部署类型**
|
||||
|
||||
关于 MySQL 数据库的部署,Kuboard 建议的做法如下:
|
||||
* 在开发环境、测试环境使用 Kuboard 部署一个副本数为 1 的 StatefulSet,以便可以快速复制 开发环境、测试环境
|
||||
* 在准上线环境和生产环境,使用 IaaS 服务商提供的 RDS 服务,原因是:
|
||||
* 直接将 MySQL 部署到 Kubernetes 虽然简便,但是数据库的运维仍然有大量的事情需要考虑,例如数据的备份、恢复、迁移等
|
||||
* Kubernetes 管理无状态服务已经非常成熟,在管理有状态的容器例如 MySQL 时,仍然需要等待更好的解决方案。当下这方面最新的进展是 [Kubernetes Operator](http://dockone.io/article/8769)
|
||||
|
||||
|
||||
**环境变量**
|
||||
|
||||
检查 [Dockerfile](https://github.com/eip-work/kuboard-example/blob/master/db-example/Dockerfile)
|
||||
|
||||
|
||||
``` Dockerfile
|
||||
FROM eipwork/mysql:5.7.26-1.1.11
|
||||
|
||||
LABEL maintainer="shaohq@foxmail.com"
|
||||
|
||||
#把数据库初始化数据的文件复制到工作目录下
|
||||
RUN mv /etc/my.cnf /etc/my.cnf.backup
|
||||
COPY docker/my.cnf /etc/my.cnf
|
||||
COPY docker/init_sql/*.sql /init_sql/
|
||||
|
||||
EXPOSE 3306
|
||||
EXPOSE 9104
|
||||
|
||||
ENV ENABLE_EUREKA_CLIENT=TRUE
|
||||
ENV eureka.name=db-example
|
||||
ENV eureka.port=80
|
||||
ENV eureka.management.port=9104
|
||||
ENV eureka.serviceUrl.default=http://monitor-eureka:9000/eureka
|
||||
```
|
||||
|
||||
Dockerfile 中定义了环境变量 ENABLE_EUREKA_CLIENT=TRUE,这个环境变量用于 Prometheus [监控套件](/guide/monitor/) 的服务发现。在不启用监控套件的情况下,应该将 ENABLE_EUREKA_CLIENT 这个环境变量设置为 FALSE。
|
||||
|
||||
::: tip
|
||||
可以在部署时覆盖环境变量的值,无需修改 Dockerfile。
|
||||
:::
|
||||
|
||||
**容器 Command 参数**
|
||||
|
||||
容器镜像 eipwork/mysql:5.7.26-1.1.11 的 Dockerfile 指定了容器的启动方式,此处无需为容器额外设置 Command 参数。
|
||||
|
||||
**访问方式及互联网入口**
|
||||
|
||||
|
||||
|
||||
|
||||
## 部署 db-example
|
||||
|
||||
**创建ConfigMap**
|
||||
|
||||
|
||||
|
||||
**创建工作负载**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 检查部署结果
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user