Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add custom define discovery #4266

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Copyright 2022 Apollo Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
eureka.client.enabled=false
spring.cloud.discovery.enabled=false
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* Default discovery service for Eureka
*/
@Service
@ConditionalOnMissingProfile({"kubernetes", "nacos-discovery", "consul-discovery", "zookeeper-discovery"})
@ConditionalOnMissingProfile({"kubernetes", "nacos-discovery", "consul-discovery", "zookeeper-discovery", "custom-defined-discovery"})
public class DefaultDiscoveryService implements DiscoveryService {

private final EurekaClient eurekaClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* </ul>
*/
@Service
@Profile({"kubernetes"})
@Profile({"kubernetes", "custom-defined-discovery"})
public class KubernetesDiscoveryService implements DiscoveryService {
private static final Splitter COMMA_SPLITTER = Splitter.on(",").omitEmptyStrings().trimResults();
private static final Map<String, String> SERVICE_ID_TO_CONFIG_NAME = ImmutableMap
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Copyright 2022 Apollo Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
apollo.eureka.server.enabled=false
eureka.client.enabled=false
spring.cloud.discovery.enabled=false
16 changes: 15 additions & 1 deletion docs/zh/deployment/distributed-deployment-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,21 @@ spring.cloud.zookeeper.connect-string=127.0.0.1:2181
admin.enableServer
admin.serverPort
```

##### 2.2.1.2.10 启用custom-defined-discovery替换内置eureka
1. 修改build.sh/build.bat,将`config-service`和`admin-service`的maven编译命令更改为
```shell
mvn clean package -Pgithub -DskipTests -pl apollo-configservice,apollo-adminservice -am -Dapollo_profile=github,custom-defined-discovery -Dspring_datasource_url=$apollo_config_db_url -Dspring_datasource_username=$apollo_config_db_username -Dspring_datasource_password=$apollo_config_db_password
```
2. 配置自定义的 config-service 与 admin-service 的访问地址有两种方式:一种在mysql数据库ApolloConfigDB,表ServerConfig当中写入两条数据。
```sql
INSERT INTO `ApolloConfigDB`.`ServerConfig` (`Key`, `Value`, `Comment`) VALUES ('apollo.config-service.url', 'http://apollo-config-service', 'ConfigService 访问地址');
INSERT INTO `ApolloConfigDB`.`ServerConfig` (`Key`, `Value`, `Comment`) VALUES ('apollo.admin-service.url', 'http://apollo-admin-service', 'AdminService 访问地址');
```
另外一种修改apollo-configservice安装包中config目录下的application-github.properties
```properties
apollo.config-service.url=http://apollo-config-service
apollo.admin-service.url=http://apollo-admin-service
```
### 2.2.2 部署Apollo服务端

#### 2.2.2.1 部署apollo-configservice
Expand Down