-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from nacos-group/feature_support_grpc
Feature support grpc
- Loading branch information
Showing
28 changed files
with
1,071 additions
and
389 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# nacos-coredns-plugin [English](./README.md) # | ||
本项目提供了一个基于CoreDNS的DNS-F客户端,可以将Nacos上注册的服务导出为DNS域名。 本DNS-F客户端是应用程序进程旁边的一个专用代理进程(side car),可以将服务名作为DNS域名查询请求转发到本客户端,提供服务发现的功能。 | ||
## 快速开始 | ||
要构建和运行本 nacos-coredns 插件,操作系统必须是 Linux 或 Mac。 另外,请确保您的 nacos 服务端版本为2.0或更高级版本,以及 golang 版本为 1.17 或更高级版本, 并且必须正确配置 golang 环境(GOPATH、GOROOT)。因为需要支持 nacos2.x 版本的gRPC连接功能和 go mod 功能。 | ||
### 构建 | ||
``` | ||
git clone https://github.com/nacos-group/nacos-coredns-plugin.git | ||
cp nacos-coredns-plugin/bin/build.sh ~/ | ||
cd ~/ | ||
sh build.sh | ||
``` | ||
### 配置 | ||
运行本 nacos-coredns 插件,您需要一个配置文件。 一个标准的配置文件如下: | ||
``` | ||
. { | ||
log | ||
nacos { | ||
nacos_namespaceId public | ||
nacos_server_host console.nacos.io:8848 | ||
} | ||
forward . /etc/resolv.conf | ||
} | ||
``` | ||
* forward:未在 nacos 注册的域名将被转发到upstream。 | ||
* nacos_namespaceId:nacos namespaceId,默认为public。 | ||
* nacos_server_host:nacos 服务端的IP地址和端口,如果有两个或多个 nacos 服务端,用逗号分隔 | ||
|
||
### 运行 | ||
* 首先需要部署一个nacos服务端。 [部署参考](https://github.com/alibaba/nacos) | ||
* 其次,在nacos上注册服务。 | ||
* 然后输入配置文件 $path_to_corefile 和指定端口 $dns_port ,运行本项目 | ||
|
||
```$GOPATH/src/coredns/coredns -conf $path_to_corefile -dns.port $dns_port``` | ||
|
||
 | ||
|
||
### 服务发现例子 | ||
输入服务名 $nacos_service_name ,本项目部署的IP地址 $dns_ip 和端口 $dns_port | ||
|
||
```dig $nacos_service_name @$dns_ip -p $dns_port ``` | ||
 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env bash | ||
# cd GOPATH | ||
cd $GOPATH/src/ | ||
|
||
# remove codes | ||
rm -rf coredns | ||
rm -rf nacos-coredns-plugin | ||
|
||
# clone current codes | ||
git clone https://github.com/coredns/coredns.git | ||
git clone https://github.com/nacos-group/nacos-coredns-plugin.git | ||
|
||
# cd coredns directory | ||
cd $GOPATH/src/coredns | ||
git checkout -b v1.6.7 v1.6.7 | ||
go get github.com/cihub/seelog | ||
|
||
# copy nacos plugin to coredns | ||
cp -r ../nacos-coredns-plugin/nacos plugin/ | ||
cp -r ../nacos-coredns-plugin/forward/setup.go plugin/forward | ||
|
||
# insert nacos into plugin | ||
sed -i '' '/hosts/a\ | ||
"nacos",\ | ||
' core/dnsserver/zdirectives.go | ||
sed -i '' '/coredns\/plugin\/hosts/a\ | ||
_ "github.com/coredns/coredns/plugin/nacos"\ | ||
' core/plugin/zplugin.go | ||
sed -i '' '/hosts:hosts/a\ | ||
nacos:nacos\ | ||
' plugin.cfg | ||
# modify import | ||
# build | ||
make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
. { | ||
log | ||
nacos { | ||
upstream /etc/resolv.conf | ||
nacos_server_port 8848 | ||
} | ||
} | ||
nacos_namespaceId public | ||
nacos_server_host console.nacos.io:8848 | ||
} | ||
forward . /etc/resolv.conf | ||
} |
Oops, something went wrong.