离线:apollo
docker pull --platform linux/amd64 apolloconfig/apollo-configservice:2.2.0
docker pull --platform linux/amd64 apolloconfig/apollo-adminservice:2.2.0
docker pull --platform linux/amd64 apolloconfig/apollo-portal:2.2.0
docker save -o F:\website\webfile\apollo\apollo-configservice-2.2.0.tar apolloconfig/apollo-configservice:2.2.0
docker save -o F:\website\webfile\apollo\apollo-adminservice-2.2.0.tar apolloconfig/apollo-adminservice:2.2.0
docker save -o F:\website\webfile\apollo\apollo-portal-2.2.0.tar apolloconfig/apollo-portal:2.2.0
得到了包。导入到 k8s
ctr -n k8s.io image import xxxxxx.tar
。。。。
初始化数据库:
ctr -n k8s.io images import apollo-configservice-2.2.0.tar
ctr -n k8s.io images import apollo-adminservice-2.2.0.tar
ctr -n k8s.io images import apollo-portal-2.2.0.tar
kubectl cp apolloconfigdb.sql default/mysql-0:/tmp/
kubectl cp apolloportaldb.sql default/mysql-0:/tmp/
kubectl exec -it mysql-0 -- /bin/bash
mysql -uroot -p密码
来自官方:
https://raw.githubusercontent.com/apolloconfig/apollo/v2.2.0/scripts/sql/apolloconfigdb.sql
https://raw.githubusercontent.com/apolloconfig/apollo/v2.2.0/scripts/sql/apolloportaldb.sql
初始化数据库表
CREATE DATABASE IF NOT EXISTS ApolloConfigDB DEFAULT CHARACTER SET utf8mb4;
CREATE DATABASE IF NOT EXISTS ApolloPortalDB DEFAULT CHARACTER SET utf8mb4;
USE ApolloConfigDB;
source /tmp/apolloconfigdb.sql;
USE ApolloPortalDB;
source /tmp/apolloportaldb.sql;
创建命名空间
kubectl create ns apollo
运行
kubectl apply -f apollo-secret.yaml
kubectl apply -f apollo-configservice.yaml
kubectl apply -f apollo-adminservice.yaml
kubectl apply -f apollo-portal.yaml
kubectl get pods -n apollo
# 查看所有 Pod 状态,应该都是 Running 且 READY 为 1/1 kubectl get pods -n apollo # 查看 AdminService 日志,确认注册成功 kubectl logs -f deployment/apollo-adminservice -n apollo | grep -i "registered"
问题处理:
kubectl logs -n apollo apollo-adminservice-7b477fd746-b7xr6 | grep -i register
2026-09-08 08:37:44.455 INFO 1 --- [ main] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2026-09-08 08:37:47.942 INFO 1 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Registering application APOLLO-ADMINSERVICE with eureka with status UP
2026-09-08 08:37:48.053 INFO 1 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_APOLLO-ADMINSERVICE/apollo-adminservice-7b477fd746-b7xr6:apollo-adminservice:8090: registering service...
2026-09-08 08:37:48.562 INFO 1 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_APOLLO-ADMINSERVICE/apollo-adminservice-7b477fd746-b7xr6:apollo-adminservice:8090: registering service...
kubectl logs -n apollo apollo-portal-7477748bfb-qdnc4 -f
ERROR 1 --- [HealthChecker-1] c.c.f.a.portal.component.PortalSettings : Env is down. env: DEV, failed times: 4917, meta server address: http://apollo-configservice.apollo.svc.cluster.local:8080
2026-09-08 08:38:17.790 ERROR 1 --- [HealthChecker-1] c.c.f.a.portal.component.PortalSettings : Env health check failed, maybe because of meta server down or configure wrong meta server address. env: DEV, meta server address: http://apollo-configservice.apollo.svc.cluster.local:8080
kubectl edit deployment apollo-adminservice -n apollo
```
找到 `containers.env`,在现有 env 数组里面追加这两条:
```
env:
- name: SPRING_DATASOURCE_URL
value: "jdbc:mysql://mysql-service.default.svc.cluster.local:3306/ApolloConfigDB?characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true"
- name: SPRING_DATASOURCE_USERNAME
valueFrom:
secretKeyRef:
key: mysql-username
name: apollo-mysql-secret
- name: SPRING_DATASOURCE_PASSWORD
valueFrom:
secretKeyRef:
key: mysql-password
name: apollo-mysql-secret
# =========新增下面两行=========
- name: EUREKA_INSTANCE_PREFER_IP_ADDRESS
value: "false"
- name: EUREKA_INSTANCE_HOSTNAME
value: "apollo-adminservice.apollo.svc.cluster.local"
```
kubectl delete pod -n apollo -l app=apollo-adminservice
增加到 portal env
- name: APOLLO_PORTAL_ENV_DEV_ADMIN_SERVICE
value: "http://apollo-adminservice.apollo.svc.cluster.local:8090"
kubectl delete pod -n apollo -l app=apollo-portal

浙公网安备 33010602011771号