helm 安装 Apollo
资源清单
本文安装
EFK
依赖K8S集群
、helm
、MySQL
,本文不提供K8S集群
和helm
安装方式,MySQL
安装可以参考以下文档
软件 | 版本 |
---|---|
chart | 0.3.1 |
apollo-portal | 1.9.1 |
apollo-service | 1.9.1 |
mysql | 5.7.26 |
kubernetes | v1.19.3 |
helm | v3.8.1 |
helm
安装 apollo-service
1. 添加 apollo-service
的仓库
$ helm repo add apollo https://www.apolloconfig.com/charts/
2. 查询 apollo-service
资源
$ helm repo update
$ helm search repo apollo-service
NAME CHART VERSION APP VERSION DESCRIPTION
apollo/apollo-service 0.3.1 1.9.1 A Helm chart for Apollo Config Service and Apol...
3. 拉取 apollo-service chart
到本地
$ mkdir -p /root/apollo/apollo-service/ && cd /root/apollo/apollo-service/
# 拉取 chart 到本地 /root/apollo/apollo-service/ 目录
$ helm pull apollo/apollo-service --version 0.3.1
$ tar -zxvf apollo-service-0.3.1.tgz
$ cp apollo-service/values.yaml ./values-test.yaml
# 查看当前目录层级
$ tree -L 2
.
├── apollo-service
│ ├── Chart.yaml
│ ├── templates
│ └── values.yaml
├── apollo-service-0.3.1.tgz
└── values-test.yaml
4. 创建数据库,并初始化数据库数据
# 获取数据库初始化语句
# https://github.com/apolloconfig/apollo/blob/v1.9.1/scripts/sql/apolloconfigdb.sql
# https://raw.githubusercontent.com/apolloconfig/apollo/v1.9.1/scripts/sql/apolloconfigdb.sql
$ wget https://raw.githubusercontent.com/apolloconfig/apollo/v1.9.1/scripts/sql/apolloconfigdb.sql -O /tmp/apolloconfigdb.sql
$ kubectl cp /tmp/apolloconfigdb.sql test-middleware/mysql_host:/tmp/apolloconfigdb.sql
# 连接部署好的 Mysql 数据,创建 apollo 账户和数据库
$ mysql -h mysql_host -u root -p root123
mysql > create database ApolloConfigDB default character set utf8mb4 collate utf8mb4_unicode_ci;
mysql > grant all on ApolloConfigDB.* to 'apollo'@'%' identified by 'apollo';
# 执行数据库初始化语句
mysql > sourse /tmp/apolloconfigdb.sql
5. 对本地 values-test.yaml
修改
- 修改配置
$ cat values-test.yaml
# 服务对应外部数据库地址信息
configdb:
name: apollo-configdb
# apolloconfigdb host
host: "mysql-cluster-mysql"
port: 3306
dbName: ApolloConfigDB
# apolloconfigdb user name
userName: "apollo"
# apolloconfigdb password
password: "apollo"
# configService 配置信息
configService:
name: apollo-configservice
fullNameOverride: "apollo-configservice"
replicaCount: 1
containerPort: 8080
nodeSelector: {}
# adminService 配置信息
adminService:
name: apollo-adminservice
fullNameOverride: "apollo-adminservice"
replicaCount: 1
containerPort: 8090
nodeSelector: {}
6. 安装 apollo-service
# 创建 test-middleware 名称空间
$ kubectl create ns test-middleware
# 安装 apollo-service 集群
$ helm -n test-middleware install apollo-service apollo-service -f values-test.yaml | tee test.log
## helm -n NAMESAPCE install SERVER_NAME FILE_NAME -f CONFIG_FILE
-n 指定 kubernetes 集群名称空间
-f 指定使用的配置文件,文件中定义的配置可以覆盖 apollo-service/values.yaml 文件中配置
NAME: apollo-service
LAST DEPLOYED: Fri Jun 3 10:22:51 2022
NAMESPACE: test-middleware
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Meta service url for current release:
echo http://apollo-configservice.test-middleware:8080
For local test use:
export POD_NAME=$(kubectl get pods --namespace test-middleware -l "app=apollo-configservice" -o jsonpath="{.items[0].metadata.name}")
echo http://127.0.0.1:8080
kubectl --namespace test-middleware port-forward $POD_NAME 8080:8080
Urls registered to meta service:
Config service: http://apollo-configservice.test-middleware:8080
Admin service: http://apollo-adminservice.test-middleware:8090
7. 查看部署的 apollo-service
$ helm -n test-middleware list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
apollo-service test-middleware 1 2022-06-03 10:22:51.837117832 -0400 EDT deployed apollo-service-0.3.1 1.9.1
$ kubectl get pods --namespace=test-middleware
NAME READY STATUS RESTARTS AGE
apollo-adminservice-9c9c7c884-wlrvx 1/1 Running 0 3m14s
apollo-configservice-8465fc64bb-ftrqs 1/1 Running 0 3m14s
helm
安装 apollo-portal
1. 添加 apollo-portal
的仓库
$ helm repo add apollo https://www.apolloconfig.com/charts/
2. 查询 apollo-portal
资源
$ helm repo update
$ helm search repo apollo-portal
NAME CHART VERSION APP VERSION DESCRIPTION
apollo/apollo-portal 0.3.1 1.9.1 A Helm chart for Apollo Portal
3. 拉取 apollo-portal chart
到本地
$ mkdir -p /root/apollo/apollo-portal/ && cd /root/apollo/apollo-portal/
# 拉取 chart 到本地 /root/apollo/apollo-portal/ 目录
$ helm pull apollo/apollo-portal --version 0.3.1
$ tar -zxvf apollo-portal-0.3.1.tgz
$ cp apollo-portal/values.yaml ./values-test.yaml
# 查看当前目录层级
$ tree -L 2
.
├── apollo-portal
│ ├── Chart.yaml
│ ├── templates
│ └── values.yaml
├── apollo-portal-0.3.1.tgz
└── values-test.yaml
4. 创建数据库,并初始化数据库数据
# 获取数据库初始化语句
# https://github.com/apolloconfig/apollo/blob/v1.9.1/scripts/sql/apolloportaldb.sql
# https://raw.githubusercontent.com/apolloconfig/apollo/v1.9.1/scripts/sql/apolloportaldb.sql
$ wget https://raw.githubusercontent.com/apolloconfig/apollo/v1.9.1/scripts/sql/apolloportaldb.sql -O /tmp/apolloportaldb.sql
$ kubectl cp /tmp/apolloportaldb.sql test-middleware/mysql_host:/tmp/apolloportaldb.sql
# 连接部署好的 Mysql 数据,创建 apollo 账户和数据库
$ mysql -h mysql_host -u root -p root123
mysql > create database ApolloPortalDB default character set utf8mb4 collate utf8mb4_unicode_ci;
mysql > grant all on ApolloPortalDB.* to 'apollo'@'%';
# 执行数据库初始化语句
mysql > sourse /tmp/apolloportaldb.sql
5. 对本地 values-test.yaml
修改
- 修改配置
$ cat values-test.yaml
name: apollo-portal
fullNameOverride: "apollo-portal"
replicaCount: 1
containerPort: 8070
# SVC 配置
service:
fullNameOverride: ""
port: 8070
targetPort: 8070
type: ClusterIP
sessionAffinity: ClientIP
# ingress 配置,方便集群外访问
ingress:
enabled: true
annotations: {}
hosts:
- host: "apollo.evescn.com"
paths: [/]
tls: []
nodeSelector: {}
# 配置定义,定义当前 apollo 的环境以及对应环境的 configservice 地址,支持配置多个环境,网络上可以访问即可, dev,fat,uat,prod 参数
config:
envs: fat
metaServers:
fat: http://apollo-configservice.test-middleware:8080
# 服务对应外部数据库地址信息
portaldb:
name: apollo-portaldb
# apolloportaldb host
host: "mysql-cluster-mysql"
port: 3306
dbName: ApolloPortalDB
# apolloportaldb user name
userName: apollo
# apolloportaldb password
password: apollo
6. 安装 apollo-portal
# 安装 apollo-portal 集群
$ helm -n test-middleware install apollo-portal apollo-portal -f values-test.yaml | tee test.log
## helm -n NAMESAPCE install SERVER_NAME FILE_NAME -f CONFIG_FILE
-n 指定 kubernetes 集群名称空间
-f 指定使用的配置文件,文件中定义的配置可以覆盖 apollo-portal/values.yaml 文件中配置
NAME: apollo-portal
LAST DEPLOYED: Fri Jun 3 09:43:42 2022
NAMESPACE: test-middleware
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Portal url for current release:
export POD_NAME=$(kubectl get pods --namespace test-middleware -l "app=apollo-portal" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8070 to use your application"
kubectl --namespace test-middleware port-forward $POD_NAME 8070:8070
Ingress:
http://apollo.evescn.com/
7. 查看部署的 apollo-portal
$ helm -n test-middleware list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
apollo-portal test-middleware 1 2022-06-03 09:43:42.750167351 -0400 EDT deployed apollo-portal-0.3.1 1.9.1
$ kubectl get pods --namespace=test-middleware -l app=apollo-portal
NAME READY STATUS RESTARTS AGE
apollo-portal-6d49d7ff95-zfnkh 1/1 Running 0 10m
8. 验证 apollo-portal
-
访问
apollo-portal
-
成功登陆
apollo-portal
-
查看
apollo-portal
环境信息
参考文档
https://artifacthub.io/packages/helm/apollo/apollo-service/0.3.1
https://artifacthub.io/packages/helm/apollo/apollo-portal
https://www.apolloconfig.com/#/zh/deployment/distributed-deployment-guide?id=_24-kubernetes%e9%83%a8%e7%bd%b2