Envoy http-ingress配置
环境说明
envoy:sidecar proxy, 地址为172.31.3.2
webserver01:后端服务,地址为127.0.0.1
envoy配置文件
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: web_service_1
domains: ["*"]
routes:
- match: { prefix: "/" }
route: { cluster: local_cluster }
http_filters:
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
clusters:
- name: local_cluster
connect_timeout: 0.25s
type: STATIC
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: local_cluster
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address: { address: 127.0.0.1, port_value: 8080 }
docker-compose.yaml
version: '3'
services:
envoy:
image: envoyproxy/envoy:v1.23-latest
volumes:
- ./envoy.yaml:/etc/envoy/envoy.yaml
environment:
- ENVOY_UID=0
- ENVOY_GID=0
networks:
envoymesh:
ipv4_address: 172.31.3.2
aliases:
- ingress
webserver01:
image: ikubernetes/demoapp:v1.0
environment:
- PORT=8080
- HOST=127.0.0.1
network_mode: "service:envoy"
depends_on:
- envoy
networks:
envoymesh:
driver: bridge
ipam:
config:
- subnet: 172.31.3.0/24
运行envoy
docker-compose up -d
测试envoy
# docker-compose exec envoy /bin/bash
root@78a4210a6b65:/# curl http://172.31.3.2:80
iKubernetes demoapp v1.0 !! ClientIP: 127.0.0.1, ServerName: 78a4210a6b65, ServerIP: 172.31.3.2!
root@78a4210a6b65:/# curl http://127.0.0.1:8080
iKubernetes demoapp v1.0 !! ClientIP: 127.0.0.1, ServerName: 78a4210a6b65, ServerIP: 172.31.3.2!
清理envoy
docker-compose down