[Envoy] ์์
envoy๋ nginx์ ๋น์ทํ ํฌ์ง์
์ ์๋ ๋ฆฌ๋ฒ์ค ํ๋ก์ ์์คํ
์ด๋ค.
2016๋ ์ ๋์๋ค. ๋ฉ์ด์ ํ ํ๋ก์ ์์คํ ๋ค ์ค์๋ ๊ฐ์ฅ ์ ์ ๋ ์์ด๋ค.
์ฃผ๋ ์ฌ์ฉ์ฒ๋ ์ญ์ ๋ก๋๋ฐธ๋ฐ์๋ฅผ ๋ง๋๋ ๊ฒ์ด๋ค.
๋ณด๋๊น GCP์์ ์ ๊ณตํ๋ ๋ก๋๋ฐธ๋ฐ์๋ envoy๋ก ๋ง๋ ๊ฑฐ๋๋ผ.
ํ๋ก๋์
์๋ ์์ธ๋ก ๋ง์ด ์ฌ์ฉ๋๋ ํธ์ด๋ค.
์ฅ์ ์ ํ๋ถํ ๊ธฐ๋ฅ๊ณผ ๋ฐ์ด๋ ์ฑ๋ฅ์ด๋ค.
MSA์ ๋ํ ์ง์๋ ๋น ๋ฆฟํด์, grpc, protobuf์ ๋ํ ๊ธฐ๋ฅ๋ ์ง์ํ๋ค.
์ฑ๋ฅ๋ง ๋๊ณ ๋ณด๋ฉด envoy๊ฐ nginx๋ณด๋ค 2๋ฐฐ ์ ๋๋ ๋น ๋ฅด๋ค.
๊ทธ๋ฆฌ๊ณ ์์ํ ์คํ์์ค๋ ์ ๋ ํน๊ธฐํ ๋งํ ๋ถ๋ถ์ด๋ค. ๊ฒฝ์์์ธ nginx์ HAProxy๋ ์คํ์์ค์ด๊ธด ํ์ง๋ง, ๊ธฐ์
์ฒด๊ฐ ๋ณด์ -๊ด๋ฆฌํ๊ณ ์์ผ๋ฉฐ, ์คํ์์ค ๋ฒ์ ๊ณผ ์์
์ฉ ๋ฒ์ ์ ๊ธฐ๋ฅ ์ฐจ๋ณ์ด ์กด์ฌํ๋ค.
๊ทธ๋ฐ ๋ถ๋ถ์์ envoy๋ ๋งค์ฐ ๋
๋ฆฝ์ ์ด๊ณ ๊นจ๋ํ ํธ์ด๋ค.
์ค์น
์์ธํ ๊ฒ์ ์ค์น ํ์ด์ง๋ฅผ ์ฐธ๊ณ ํ๋ค.
https://www.envoyproxy.io/docs/envoy/latest/start/install
์ค์น ๋ฐ ์คํ
์ฐ๋ถํฌ์์๋ ๋ค์ ๋ช ๋ น์ ์ฌ์ฉํด์ ์ค์นํ ์ ์๋ค.
sudo apt update
sudo apt install apt-transport-https gnupg2 curl lsb-release
curl -sL 'https://deb.dl.getenvoy.io/public/gpg.8115BA8E629CC074.key' | sudo gpg --dearmor -o /usr/share/keyrings/getenvoy-keyring.gpg
Verify the keyring - this should yield "OK"
echo a077cb587a1b622e03aa4bf2f3689de14658a9497a9af2c427bba5f4cc3c4723 /usr/share/keyrings/getenvoy-keyring.gpg | sha256sum --check
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/getenvoy-keyring.gpg] https://deb.dl.getenvoy.io/public/deb/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/getenvoy.list
sudo apt update
sudo apt install -y getenvoy-envoy

์ค์น๊ฐ ์ ๋๋ค๋ฉด cli๋ก ์คํํ ์ ์๋ค.

docker๋ฅผ ์ฌ์ฉํ ๋๋ ์ด๋ ๊ฒ ๊ฐ์ ธ์์ ์ฐ๋ฉด ๋๋ค.
latest ํ๊ทธ๊ฐ ์์ด์ ํญ์ ๋ฒ์ ์ ๋ช
์ํด์ผ ํ๊ณ , nginx์๋ ๋ค๋ฅด๊ฒ ๊ธฐ๋ณธ๋์์ด ์์ด์ ์ค์ ํ์ผ์ ๋ฃ์ด์ฃผ์ง ์์ผ๋ฉด ๋ญ๊ฐ ๋ฐ๋ก ๋์ํ์ง๋ ์๋๋ค.
docker pull envoyproxy/envoy:v1.26-latest
docker run envoyproxy/envoy:v1.26-latest


ํ๋ก์ฑํด๋ณด๊ธฐ
๋ค๋ฅธ ์๋ฒ๋ฅผ ํ๋ก์ฑํ๋ ๊ฐ๋จํ ๋ก๋๋ฐธ๋ฐ์๋ฅผ ๊ตฌํํด๋ณด์.
์ผ๋จ ๋ก์ปฌ 12345 ํฌํธ์ ๊ฐ๋จํ ์๋ฒ๋ฅผ ๋์๋จ๋ค.
์ ๊ฑธ ํ๋ก์ฑํ๊ฒ ํ๊ฒ ๋ค.
๋ค์๊ณผ ๊ฐ์ ํํ๋ก yaml์ ์ง์ค๋ค.
static_resources:
listeners:
- name: listener_0
address:
socket_address: { address: 0.0.0.0, port_value: 80 }
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
stat_prefix: ingress_http
codec_type: AUTO
route_config:
name: local_route
virtual_hosts:
- name: local_service
domains: ["*"]
routes:
- match: { prefix: "/" }
route: { cluster: some_service }
http_filters:
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
clusters:
- name: some_service
connect_timeout: 0.25s
type: STATIC
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: some_service
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: 0.0.0.0
port_value: 12345
๋ฆฌ์ค๋๋ ์ธ๋ถ์์ ํธ๋ํฝ์ ๋ฐ์์ ์ฒ๋ฆฌํ๋ ์์ญ์ ์ ์ํ๋ค. ์ฌ๊ธฐ์๋ 0.0.0.0:80๋ก ํด์ 80 http๋ก ์ ๊ทผํ ์ ์๊ฒ ํ๋ค. ๊ทธ๋ฆฌ๊ณ ๋ฐ์์ ํ ํด๋ฌ์คํฐ ์ค์ ์ผ๋ก ํธ๋ํฝ์ ๋ผ์ฐํ ํ๋ค.
๋ฆฌ์ค๋๊ฐ ํ๋ก ํธ์๋๋ฉด ํด๋ฌ์คํฐ๊ฐ ๋ฐฑ์๋์ธ ์ ์ด๋ค. ํด๋ฌ์คํฐ์์๋ ๋ก์ปฌ์ ๋ ์๋ 12345 ํฌํธ ์๋ฒ๋ฅผ ๊ฐ๋ฆฌํค๋๋ก ๊ตฌ์ฑํ๋ค.
์ ๋ ๊ฒ ๋ง๋ค์ด๋๊ณ cli๋ก ์คํ์ ํด์ฃผ๋ฉด ์ค์ ํ์ผ์ด ์ง์ ๋จ๊ณผ ๋์์ ์ฌ์คํ์ด ๋๋ค.

๊ทธ๋ผ ์ ๋ ๊ฒ์ด๋ค.

์ฐธ์กฐ
https://tech.cloudmt.co.kr/2023/03/16/230316/
https://www.google.com/search?q=nginx+vs+envoy&oq=nginx+vs+en&aqs=chrome.0.0i512j69i57j0i30l4j0i8i30l4.7255j0j7&client=ms-android-samsung-ss&sourceid=chrome-mobile&ie=UTF-8
https://bcho.tistory.com/m/1253
https://www.envoyproxy.io/docs/envoy/latest/start/quick-start/run-envoy