[GitHub] [apisix-website] Fabriceli commented on a diff in pull request #1478: docs: add apisix with consul blog

2023-01-19 Thread GitBox


Fabriceli commented on code in PR #1478:
URL: https://github.com/apache/apisix-website/pull/1478#discussion_r1082069199


##
blog/en/blog/2023/01/18/consul-with-apisix.md:
##
@@ -0,0 +1,274 @@
+---
+title: "How to Integrate API Gateway and Consul? Not Consul K/V"
+authors:
+  - name: "Yihao LI"
+title: "Author"
+url: "https://github.com/Fabriceli;
+image_url: "https://github.com/Fabriceli.png;
+keywords:
+- API Gateway
+- Consul
+- Service Discovery
+- Service Register
+description: Apache APISIX supports the Consul service discovery registry. 
This article will walk you through the process of implementing service 
discovery and service registry in APISIX.
+tags: [Ecosystem]
+image: 
https://static.apiseven.com/2022/blog/0818/ecosystem/HashiCorp%20Consul.png
+---
+

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [apisix-website] Fabriceli commented on a diff in pull request #1478: docs: add apisix with consul blog

2023-01-18 Thread GitBox


Fabriceli commented on code in PR #1478:
URL: https://github.com/apache/apisix-website/pull/1478#discussion_r1080763913


##
blog/zh/blog/2023/01/18/consul-with-apisix.md:
##
@@ -0,0 +1,271 @@
+---
+title: "Apache APISIX 集成原生 Consul 服务发现能力"
+authors:
+  - name: "李奕浩"
+title: "Author"
+url: "https://github.com/Fabriceli;
+image_url: "https://github.com/Fabriceli.png;
+  - name: "李奕浩"
+title: "Technical Writer"
+url: "https://github.com/Fabriceli;
+image_url: "https://github.com/Fabriceli.png;
+keywords:
+- API Gateway
+- Consul
+- 服务发现
+- 服务注册
+description: 云原生 API 网关 Apache APISIX 支持基于 Consul 的服务发现。本文讲述了在 Apache APISIX 
中实现服务发现和服务注册的全过程及 consul 的相关原理。

Review Comment:
   done



##
blog/zh/blog/2023/01/18/consul-with-apisix.md:
##
@@ -0,0 +1,271 @@
+---
+title: "Apache APISIX 集成原生 Consul 服务发现能力"
+authors:
+  - name: "李奕浩"
+title: "Author"
+url: "https://github.com/Fabriceli;
+image_url: "https://github.com/Fabriceli.png;
+  - name: "李奕浩"
+title: "Technical Writer"
+url: "https://github.com/Fabriceli;
+image_url: "https://github.com/Fabriceli.png;

Review Comment:
   done



##
blog/en/blog/2023/01/18/consul-with-apisix.md:
##
@@ -0,0 +1,278 @@
+---
+title: "How to Integrate API Gateway and Consul? Not Consul K/V"
+authors:
+  - name: "Yihao LI"
+title: "Author"
+url: "https://github.com/Fabriceli;
+image_url: "https://github.com/Fabriceli.png;
+  - name: "Yihao LI"
+title: "Technical Writer"
+url: "https://github.com/Fabriceli;
+image_url: "https://github.com/Fabriceli.png;

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [apisix-website] Fabriceli commented on a diff in pull request #1478: docs: add apisix with consul blog

2023-01-18 Thread GitBox


Fabriceli commented on code in PR #1478:
URL: https://github.com/apache/apisix-website/pull/1478#discussion_r1080763797


##
blog/zh/blog/2023/01/18/consul-with-apisix.md:
##
@@ -0,0 +1,271 @@
+---
+title: "Apache APISIX 集成原生 Consul 服务发现能力"
+authors:
+  - name: "李奕浩"
+title: "Author"
+url: "https://github.com/Fabriceli;
+image_url: "https://github.com/Fabriceli.png;
+  - name: "李奕浩"
+title: "Technical Writer"
+url: "https://github.com/Fabriceli;
+image_url: "https://github.com/Fabriceli.png;
+keywords:
+- API Gateway
+- Consul
+- 服务发现
+- 服务注册
+description: 云原生 API 网关 Apache APISIX 支持基于 Consul 的服务发现。本文讲述了在 Apache APISIX 
中实现服务发现和服务注册的全过程及 consul 的相关原理。
+tags: [Ecosystem]
+image: 
https://static.apiseven.com/2022/blog/0818/ecosystem/HashiCorp%20Consul.png
+---
+
+## 背景
+
+### 关于 Apache APISIX
+
+Apache APISIX 是 Apache 软件基金会下的云原生 API 
网关,它兼具动态、实时、高性能等特点,提供了负载均衡、动态上游、灰度发布(金丝雀发布)、服务熔断、身份认证、可观测性等丰富的流量管理功能。我们可以使用 
Apache APISIX 来处理传统的南北向流量,也可以处理服务间的东西向流量。
+
+### 关于 Consul
+
+Consul 是 HashiCorp 公司推出的开源工具,用于实现分布式系统的服务发现与配置,提供了服务注册与发现、健康检查、Key/Value 
存储、多数据中心的能力。
+
+## 准备阶段
+
+本文中的测试环境使用 docker-compose 搭建
+
+1. 下载 Apache APISIX
+
+   ```sh
+   git clone https://github.com/apache/apisix-docker.git
+   ```
+
+2. 创建并运行 Consul
+
+   ```sh
+   docker run --rm --name consul_1 -d -p 8500:8500 consul:1.8 consul agent 
-server -bootstrap-expect=1 -node=agent-one -client 0.0.0.0 -log-level info 
-data-dir=/consul/data -enable-script-checks
+   ```
+
+3. 更新 Apache APISIX 中的配置文件`apisix_conf/config.yaml`
+
+   ```yaml
+   # config.yml
+   # ... other config
+   discovery:
+ consul:
+   servers:
+ - "http://127.0.0.1:8500;
+   ```
+
+4. 启动 Apache APISIX
+
+   ```sh
+   # 进 example 文件夹,启动 APISIX
+   docker-compose -f docker-compose.yml -p apisix-docker  up -d
+   ```
+
+5. 测试服务已经包含了两个 Web 服务,确认 Web 服务的 IP 地址
+
+   ```sh
+   $ sudo docker inspect -f='{{.Name}} - {{range 
.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(sudo docker ps -aq) | grep 
web
+   # 输出
+   /apisix-docker-web1-1 - 172.21.0.5
+   /apisix-docker-web2-1 - 172.21.0.6
+   ```
+
+6. 请求 Consul HTTP API 将 Web 服务注册到 Consul
+
+   ```sh
+   # 使用 Web 对应的 IP 和 port 进行注册
+   $ curl --location --request PUT 
'http://127.0.0.1:8500/v1/agent/service/register' \
+   --header 'Content-Type: application/json' \
+   --data '{
+  "ID": "service_a1",
+  "Name": "service_a",
+  "Tags": ["primary", "v1"],
+  "Address": "172.21.0.5",
+  "Port": 9081,
+  "Weights": {
+ "Passing": 10,
+ "Warning": 1
+  }
+   }'
+
+   $ curl --location --request PUT 
'http://127.0.0.1:8500/v1/agent/service/register' \
+   --header 'Content-Type: application/json' \
+   --data '{
+  "ID": "service_a2",
+  "Name": "service_a",
+  "Tags": ["primary", "v1"],
+  "Address": "172.21.0.6",
+  "Port": 9082,
+  "Weights": {
+ "Passing": 10,
+ "Warning": 1
+  }
+   }'
+   ```
+
+7. 查看测试服务是否注册成功
+
+   ```sh
+   $ curl --location --request GET 
'http://127.0.0.1:8500/v1/catalog/service/service_a'
+   ```
+
+   其中,`/v1/catalog/service/`后的路径是服务名称,即服务注册时候的`name`。
+   返回消息体如下则表示成功注册。
+
+  ```json
+   [{
+  "ID": "7a36c6f1-f701-9c67-8db8-7b8551d36b4a",
+  "Node": "agent-one",
+  "Address": "172.23.0.2",
+  "Datacenter": "dc1",
+  "TaggedAddresses": {
+ "lan": "172.23.0.2",
+ "lan_ipv4": "172.23.0.2",
+ "wan": "172.23.0.2",
+ "wan_ipv4": "172.23.0.2"
+  },
+  "NodeMeta": {
+ "consul-network-segment": ""
+  },
+  "ServiceKind": "",
+  "ServiceID": "service_a1",
+  "ServiceName": "service_a",
+  "ServiceTags": ["primary", "v1"],
+  "ServiceAddress": "172.20.10.2",
+  "ServiceTaggedAddresses": {
+ "lan_ipv4": {
+"Address": "172.20.10.2",
+"Port": 9082
+ },
+ "wan_ipv4": {
+"Address": "172.20.10.2",
+"Port": 9082
+ }
+  },
+  "ServiceWeights": {
+ "Passing": 10,
+ "Warning": 1
+  },
+  "ServiceMeta": {},
+  "ServicePort": 9082,
+  "ServiceEnableTagOverride": false,
+  "ServiceProxy": {
+ "MeshGateway": {},
+ "Expose": {}
+  },
+  "ServiceConnect": {},
+  "CreateIndex": 46,
+  "ModifyIndex": 124
+   }, {
+  "ID": "7a36c6f1-f701-9c67-8db8-7b8551d36b4a",
+  "Node": "agent-one",
+  "Address": "172.23.0.2",
+  "Datacenter": "dc1",
+  "TaggedAddresses": {
+ "lan": "172.23.0.2",
+ "lan_ipv4": "172.23.0.2",
+ "wan": "172.23.0.2",
+ "wan_ipv4": "172.23.0.2"
+  },
+  "NodeMeta": {
+ "consul-network-segment": ""
+  },
+  "ServiceKind": "",
+  "ServiceID": "service_a2",
+  "ServiceName": "service_a",
+  "ServiceTags": ["primary", "v1"],
+  "ServiceAddress": "172.20.10.2",
+  "ServiceTaggedAddresses": {
+ "lan_ipv4": {
+"Address":