apollo官网:官方地址

apollo架构图:

apollo需要使用数据库,这里使用mysql,注意版本需要在5.6以上:

本次环境mysql部署在10.4.7.11上,使用mariadb:10.1以上版本

# vi /etc/yum.repos.d/MariaDB.repo
[mariadb]
name = MariaDB
baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.1/centos7-amd64/
gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1

导入key:

# rpm --import https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
# yum install MariaDB-server -y

简单配置mysql:

# vi /etc/my.cnf.d/server.cnf
[mysqld]
character_set_server = utf8mb4
collation_server = utf8mb4_general_ci
init_connect = "SET NAMES 'utf8mb4'"
# vi /etc/my.cnf.d/mysql-clients.cnf
[mysql]
default-character-set = utf8mb4
# systemctl start mariadb
# systemctl enable mariadb
# mysqladmin -u root password 

登录检查字符集:

# mysql -uroot -p
> \s

执行数据库初始化脚本:configdb初始化脚本

下载脚本:

# wget https://raw.githubusercontent.com/ctripcorp/apollo/1.5.1/scripts/db/migration/configdb/V1.0.0__initialization.sql -O apolloconfig.sql

执行初始化脚本:

# mysql -uroot -p < apolloconfig.sql

检查数据库:

给数据库授权:

# grant INSERT,DELETE,UPDATE,SELECT on ApolloConfigDB.* to 'apolloconfig'@'10.4.7.%'  identified by "123456";

修改初始化数据:

> update ServerConfig set Value='http://config.od.com/eureka' where Id=1;
也可以使用下面的sql:执行一个即可
 > update ApolloConfigDB.ServerConfig set ServerConfig.Value="http://config.od.com/eureka" where ServerConfig.Key="eureka.service.url";

添加config域名解析:

# vi /var/named/od.com.zone
# systemctl restart named

测试域名解析:

# dig  -t A config.od.com @10.4.7.11 +short

交付顺序:

  1、apolloconfigservice

  2、adminservice

  3、portal

下载apolloconfigservice的包:放到200上,制作镜像

# wget https://github.com/ctripcorp/apollo/releases/download/v1.5.1/apollo-configservice-1.5.1-github.zip
# mkdir /data/dockerfile/apollo-configservice
# unzip -o apollo-configservice-1.5.1-github.zip -d /data/dockerfile/apollo-configservice/
# cd /data/dockerfile/apollo-configservice/

修改连接数据库配置:

# cd config
# vi application-github.properties

添加mysql.od.com域名解析:

修改启动脚本:

# cd scripts/
# vi startup.sh

将官网上的startup.sh内容替换进来 脚本地址

添加一行:

APOLLO_CONFIG_SERVICE_NAME=$(hostname -i)

自行优化JVM

添加执行权限:

# chmod u+x startup.sh

编写dockerfile:官方地址

# cd ..
# vi Dockerfile
FROM harbor.od.com/base/jre8:8u112

ENV VERSION 1.5.1

RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime &&\
echo "Asia/Shanghai" > /etc/timezone ADD apollo-configservice-${VERSION}.jar /apollo-configservice/apollo-configservice.jar
ADD config/ /apollo-configservice/config
ADD scripts/ /apollo-configservice/scripts CMD ["/apollo-configservice/scripts/startup.sh"]
# docker build . -t harbor.od.com/infra/apollo-configservice:v1.5.1
# docker push harbor.od.com/infra/apollo-configservice:v1.5.1

编写资源配置清单:

# cd /data/k8s-yaml/
# mkdir apollo-configservice
# cd apollo-configservice

1、cm.yaml

apiVersion: v1
kind: ConfigMap
metadata:
name: apollo-configservice-cm
namespace: infra
data:
application-github.properties: |
# DataSource
spring.datasource.url = jdbc:mysql://mysql.od.com:3306/ApolloConfigDB?characterEncoding=utf8
spring.datasource.username = apolloconfig
spring.datasource.password = 123456
eureka.service.url = http://config.od.com/eureka
app.properties: |
appId=100003171

2、dp.yaml

kind: Deployment
apiVersion: extensions/v1beta1
metadata:
name: apollo-configservice
namespace: infra
labels:
name: apollo-configservice
spec:
replicas: 1
selector:
matchLabels:
name: apollo-configservice
template:
metadata:
labels:
app: apollo-configservice
name: apollo-configservice
spec:
volumes:
- name: configmap-volume
configMap:
name: apollo-configservice-cm
containers:
- name: apollo-configservice
image: harbor.od.com/infra/apollo-configservice:v1.5.1
ports:
- containerPort: 8080
protocol: TCP
volumeMounts:
- name: configmap-volume
mountPath: /apollo-configservice/config
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: IfNotPresent
imagePullSecrets:
- name: harbor
restartPolicy: Always
terminationGracePeriodSeconds: 30
securityContext:
runAsUser: 0
schedulerName: default-scheduler
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
revisionHistoryLimit: 7
progressDeadlineSeconds: 600

3、svc.yaml

kind: Service
apiVersion: v1
metadata:
name: apollo-configservice
namespace: infra
spec:
ports:
- protocol: TCP
port: 8080
targetPort: 8080
selector:
app: apollo-configservice

4、ingress.yaml

kind: Ingress
apiVersion: extensions/v1beta1
metadata:
name: apollo-configservice
namespace: infra
spec:
rules:
- host: config.od.com
http:
paths:
- path: /
backend:
serviceName: apollo-configservice
servicePort: 8080

应用资源配置清单:

# kubectl create -f http://k8s-yaml.od.com/apollo-configservice/cm.yaml
# kubectl create -f http://k8s-yaml.od.com/apollo-configservice/dp.yaml
# kubectl create -f http://k8s-yaml.od.com/apollo-configservice/svc.yaml
# kubectl create -f http://k8s-yaml.od.com/apollo-configservice/ingress.yaml

检查启动情况:

需要等到eureka启动以后才可以,接下来使用浏览器访问config.od.com:

下载adminservice:官方地址放在200上

# wget https://github.com/ctripcorp/apollo/releases/download/v1.5.1/apollo-adminservice-1.5.1-github.zip
# mkdir /data/dockerfile/apollo-adminservice
# unzip -o apollo-adminservice-1.5.1-github.zip -d /data/dockerfile/apollo-adminservice/
# cd /data/dockerfile/apollo-adminservice/

由于使用了configmap资源将配置文件挂载出来了,所以不在修改配置文件,如需修改配置文件,请参考部署apollo-configservice时候的修改方法:

修改startup.sh:  官方地址

将端口修改为:8080

添加以下一项配置:

APOLLO_ADMIN_SERVICE_NAME=$(hostname -i)

制作dockerfile:

# vi Dockerfile
FROM stanleyws/jre8:8u112

ENV VERSION 1.5.1

RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime &&\
echo "Asia/Shanghai" > /etc/timezone ADD apollo-adminservice-${VERSION}.jar /apollo-adminservice/apollo-adminservice.jar
ADD config/ /apollo-adminservice/config
ADD scripts/ /apollo-adminservice/scripts CMD ["/apollo-adminservice/scripts/startup.sh"]

制作资源配置清单:

# mkdir /data/k8s-yaml/apollo-adminservice && cd /data/k8s-yaml/apollo-adminservice 

1、cm.yaml

apiVersion: v1
kind: ConfigMap
metadata:
name: apollo-adminservice-cm
namespace: infra
data:
application-github.properties: |
# DataSource
spring.datasource.url = jdbc:mysql://mysql.od.com:3306/ApolloConfigDB?characterEncoding=utf8
spring.datasource.username = apolloconfig
spring.datasource.password = 123456
eureka.service.url = http://config.od.com/eureka
app.properties: |
appId=100003172

2、dp.yaml

kind: Deployment
apiVersion: extensions/v1beta1
metadata:
name: apollo-adminservice
namespace: infra
labels:
name: apollo-adminservice
spec:
replicas: 1
selector:
matchLabels:
name: apollo-adminservice
template:
metadata:
labels:
app: apollo-adminservice
name: apollo-adminservice
spec:
volumes:
- name: configmap-volume
configMap:
name: apollo-adminservice-cm
containers:
- name: apollo-adminservice
image: harbor.od.com/infra/apollo-adminservice:v1.5.1
ports:
- containerPort: 8080
protocol: TCP
volumeMounts:
- name: configmap-volume
mountPath: /apollo-adminservice/config
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: IfNotPresent
imagePullSecrets:
- name: harbor
restartPolicy: Always
terminationGracePeriodSeconds: 30
securityContext:
runAsUser: 0
schedulerName: default-scheduler
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
revisionHistoryLimit: 7
progressDeadlineSeconds: 600

应用资源配置清单:

# kubectl create -f http://k8s-yaml.od.com/apollo-adminservice/cm.yaml
# kubectl create -f http://k8s-yaml.od.com/apollo-adminservice/dp.yaml

通过日志检查启动情况:

通过config.od.com检查是否注册到了eureka:

已经顺利的注册到了注册中心中。

接下来交付portal:官方地址  200上下载并制作镜像

# wget https://github.com/ctripcorp/apollo/releases/download/v1.5.1/apollo-portal-1.5.1-github.zip
# mkdir /data/dockerfile/apollo-portal
# unzip -o apollo-portal-1.5.1-github.zip -d /data/dockerfile/apollo-portal/
# cd /data/dockerfile/apollo-portal/

由于portal使用的是另一个portaldb,我们需要在数据库中新建portdb,并初始化:初始化脚本

在7-21上下载下来脚本:

# wget https://raw.githubusercontent.com/ctripcorp/apollo/1.5.1/scripts/db/migration/portaldb/V1.0.0__initialization.sql -O apollo-portal.sql
# mysql -uroot -p
]> source ./apollo-portal.sq

创建用户并授权:

# grant INSERT,DELETE,UPDATE,SELECT on ApolloPortalDB.* to "apolloportal"@"10.4.7.%" identified by "123456";

修改数据库:

创建部门:

]> update ServerConfig set Value='[{"orgId":"od01","orgName":"Linux学院"},{"orgId":"od02","orgName":"云计算学院"},{"orgId":"od03","orgName":"Python学院"}]' where Id=2;

由于使用concigmap资源,故之做介绍,不在这里修改:

配置portal meta serice:

这里列出的是支持的环境列表配置:

# vi /data/dockerfile/apollo-portal/config/apollo-env.properties

修改startup.sh 官方地址

修改端口为8080

添加以下配置项:

APOLLO_PORTAL_SERVICE_NAME=$(hostname -i)

制作dockerfile:

# vi Dockerfile
FROM stanleyws/jre8:8u112

ENV VERSION 1.5.1

RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime &&\
echo "Asia/Shanghai" > /etc/timezone ADD apollo-portal-${VERSION}.jar /apollo-portal/apollo-portal.jar
ADD config/ /apollo-portal/config
ADD scripts/ /apollo-portal/scripts CMD ["/apollo-portal/scripts/startup.sh"]
# docker build . -t harbor.od.com/infra/apollo-portal:v1.5.1
# docker push harbor.od.com/infra/apollo-portal:v1.5.1

编写资源配置清单:

# mkdir /data/k8s-yaml/apollo-portal && cd /data/k8s-yaml/apollo-portal

1、cm.yaml

apiVersion: v1
kind: ConfigMap
metadata:
name: apollo-portal-cm
namespace: infra
data:
application-github.properties: |
# DataSource
spring.datasource.url = jdbc:mysql://mysql.od.com:3306/ApolloPortalDB?characterEncoding=utf8
spring.datasource.username = apolloportal
spring.datasource.password = 123456
app.properties: |
appId=100003173
apollo-env.properties: |
dev.meta=http://config.od.com

2、dp.yaml

kind: Deployment
apiVersion: extensions/v1beta1
metadata:
name: apollo-portal
namespace: infra
labels:
name: apollo-portal
spec:
replicas: 1
selector:
matchLabels:
name: apollo-portal
template:
metadata:
labels:
app: apollo-portal
name: apollo-portal
spec:
volumes:
- name: configmap-volume
configMap:
name: apollo-portal-cm
containers:
- name: apollo-portal
image: harbor.od.com/infra/apollo-portal:v1.5.1
ports:
- containerPort: 8080
protocol: TCP
volumeMounts:
- name: configmap-volume
mountPath: /apollo-portal/config
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: IfNotPresent
imagePullSecrets:
- name: harbor
restartPolicy: Always
terminationGracePeriodSeconds: 30
securityContext:
runAsUser: 0
schedulerName: default-scheduler
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
revisionHistoryLimit: 7
progressDeadlineSeconds: 600

3、svc.yaml

kind: Service
apiVersion: v1
metadata:
name: apollo-portal
namespace: infra
spec:
ports:
- protocol: TCP
port: 8080
targetPort: 8080
selector:
app: apollo-portal

4、ingress.yaml

kind: Ingress
apiVersion: extensions/v1beta1
metadata:
name: apollo-portal
namespace: infra
spec:
rules:
- host: portal.od.com
http:
paths:
- path: /
backend:
serviceName: apollo-portal
servicePort: 8080

应用资源配置清单:

# kubectl create -f http://k8s-yaml.od.com/apollo-portal/cm.yaml
# kubectl create -f http://k8s-yaml.od.com/apollo-portal/dp.yaml
# kubectl create -f http://k8s-yaml.od.com/apollo-portal/svc.yaml
# kubectl create -f http://k8s-yaml.od.com/apollo-portal/ingress.yaml

添加域名解析:portal.od.com

网页访问 portal.od.com

默认用户名:apollo

默认密码:   admin

到此,apollo的三个组件都已经交付到k8s里了。

kubernetes实战-配置中心(二)交付apollo配置中心到k8s的更多相关文章

  1. SpringBoot自动化配置之二:自动配置(AutoConfigure)原理、EnableAutoConfiguration、condition

    自动配置绝对算得上是Spring Boot的最大亮点,完美的展示了CoC约定优于配置: Spring Boot能自动配置Spring各种子项目(Spring MVC, Spring Security, ...

  2. 【Nacos】Springboot整合Nacos配置中心(二) 多环境配置

    本篇随笔接上一篇文章:Springboot整合Nacos配置中心(一),主要记录Nacos多环境的配置的方法 Nacos多环境的配置 方法一: 1.在项目中的bootstrap.yaml文件中配置激活 ...

  3. AlwaysOn可用性组测试环境安装与配置(二)--AlwaysOn配置(界面与T-SQL)

    四.AlwaysOn配置 1.开启AlwaysOn高可用性功能. 1.1.开启Server01的可用性组 1.2.需要重启服务:属于SQL server群集节点的服务,需要通过故障转移界面重启 1.3 ...

  4. Openfire开发配置,Openfire源代码配置,OpenFire二次开发配置

    原文:http://www.cnblogs.com/lixiaolun/archive/2013/12/07/3462780.html 1.下载源代码:http://www.igniterealtim ...

  5. Openfire开发配置,Openfire源码配置,OpenFire二次开发配置

    1.下载源码:http://www.igniterealtime.org/downloads/source.jsp 2.把源码解压出的openfire_src目录放至eclipse workplace ...

  6. TensorFlow-GPU环境配置之二——CUDA环境配置

    1.安装最新显卡驱动 到系统设置->软件和更新->附加驱动中选中最新的显卡驱动,并应用 2.下载CUDA8.0 https://developer.nvidia.com/cuda-down ...

  7. Openfire开发配置,Openfire源代码配置,OpenFire二次开发配置(eclipse)

    首先去官网把openfire的源码下下来: http://www.igniterealtime.org/downloads/source.jsp 1.下载后放到你的workspace当中,我的woek ...

  8. K8S(11)配置中心实战-单环境交付apollo三组件

    k8s配置中心实战-交付apollo三组件 目录 k8s配置中心实战-交付apollo三组件 1 apollo简单说明 1.1 apollo最简架构图: 1.2 apollo组件部署关系 2 为app ...

  9. K8S(12)配置中心实战-多环境交付apollo三组件

    k8s配置中心实战-多环境交付apollo三组件 目录 k8s配置中心实战-多环境交付apollo三组件 1.环境准备工作 1.1 zk环境拆分 1.2 namespace分环境 1.3 数据库拆分 ...

随机推荐

  1. DOS的FOR命令用法总结

    鉴于dos自带的关于for命令的帮助信息看起来太简单,自己总结了一下,并增加了必要的实例,以备日后自己查阅.其中一些地方可能存在理解错误,敬请指出. [转发请注明出处]

  2. Kubernetes CoreDNS 状态是 CrashLoopBackOff 报错

    查看状态的时候,遇见coredns出现crashlookbackoff,首先我们来进行排错,不管是什么原因,查看coredns的详细信息,以及logs [root@k8s-master coredns ...

  3. Windows程序通用自动更新模块(C#,.NET4.5以上)

    本通用自动更新模块适合所有Windows桌面程序的自动更新,不论语言,无论Winform还是wpf. 一.工作流程:1. 主程序A调起升级程序B2. B从服务器获取更新程序列表,打印更新信息.3. B ...

  4. ios获取缓存文件的大小并清除缓存

    移动应用在处理网络资源时,一般都会做离线缓存处理,其中以图片缓存最为典型,其中很流行的离线缓存框架为SDWebImage. 但是,离线缓存会占用手机存储空间,所以缓存清理功能基本成为资讯.购物.阅读类 ...

  5. python3.8.1安装cx_Freeze

    按照官网的提示命令python -m pip install cx_Freeze --upgrade安装,不成功,报了一个错误,说cx_Freeze找不到需要的版本,还有一些警告说PIP需要升级,没理 ...

  6. Python设计模式面向对象编程

    前言   本篇文章是基于极客时间王争的<设计模式之美>做的总结和自己的理解.  说到面向对象编程,作为一个合格的Pythoner,可以说信手拈来.毕竟在Python里"万物都是对 ...

  7. VMware vSphere (EXSI) 安装使用

    VMware vSphere 镜像下载 VMware vSphere Hypervisor (ESXi) 6.7 https://my.vmware.com/cn/web/vmware/downloa ...

  8. Python学习【第8篇】:python中的函数

    1.python中函数定义方法 def test(x): "This istest" y = x*2+1 return y vaule = test(2)print(vaule)运 ...

  9. luoguP4999 烦人的数学作业

    写在前面 这两天信息量有点大,需要好好消化一下,呼呼 \(f[i][j]\) 的转移式还是好理解的,但是对于其实际意义课上有点糊 求 \(ans_{1, x}\) 是感觉手动把数拆开看会好理解一点?? ...

  10. 1. Centos 7重置root密码

    1.开机启动系统,不断按"↑"和"↓",在如下引导界面按"e",编辑引导项 2.按"↓"找到下图显示的代码 删除代码最后 ...