Envoy 部署

发布时间: 更新时间: 总字数:964 阅读时间:2m 作者:IP:上海 网址

envoy 安装部署

Ubuntu

wget -O- https://apt.envoyproxy.io/signing.key | sudo gpg --dearmor -o /etc/apt/keyrings/envoy-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/envoy-keyring.gpg] https://apt.envoyproxy.io jammy main" | sudo tee /etc/apt/sources.list.d/envoy.list
sudo apt-get update
sudo apt-get install envoy
envoy --version

Mac

brew update
brew install envoy

Docker

docker pull envoyproxy/envoy:tools-v1.35.3
docker pull envoyproxy/envoy:v1.35.3

docker run --rm envoyproxy/envoy:v1.35.3 --version
docker run --rm envoyproxy/envoy:v1.35.3 --help

help

envoy--help ...

默认配置

root@t:~# docker run -it --rm --entrypoint bash envoyproxy/envoy:v1.35.3
root@2e44e67518e7:/# ls /etc/envoy/
VERSION.txt  envoy.yaml
root@2e44e67518e7:/# cat /etc/envoy/envoy.yaml
admin:
  address:
    socket_address:
      protocol: TCP
      address: 0.0.0.0
      port_value: 9901
static_resources:
  listeners:
  - name: listener_0
    address:
      socket_address:
        protocol: TCP
        address: 0.0.0.0
        port_value: 10000
    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
          scheme_header_transformation:
            scheme_to_overwrite: https
          stat_prefix: ingress_http
          route_config:
            name: local_route
            virtual_hosts:
            - name: local_service
              domains: ["*"]
              routes:
              - match:
                  prefix: "/"
                route:
                  host_rewrite_literal: www.envoyproxy.io
                  cluster: service_envoyproxy_io
          http_filters:
          - name: envoy.filters.http.router
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
  clusters:
  - name: service_envoyproxy_io
    connect_timeout: 30s
    type: LOGICAL_DNS
    # Comment out the following line to test on v6 networks
    dns_lookup_family: V4_ONLY
    lb_policy: ROUND_ROBIN
    load_assignment:
      cluster_name: service_envoyproxy_io
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: www.envoyproxy.io
                port_value: 443
    transport_socket:
      name: envoy.transport_sockets.tls
      typed_config:
        "@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
        sni: www.envoyproxy.io

说明:

  • admin 管理端口:http://127.0.0.1:9091
  • 代理服务端口:http://127.0.0.1:10000

access log

admin:
  access_log:
  - name: envoy.access_loggers.stdout
    typed_config:
      "@type": type.googleapis.com/envoy.extensions.access_loggers.stream.v3.StdoutAccessLog

Override the default configuration

  • envoy-override.yaml
admin:
  address:
    socket_address:
      address: 127.0.0.1
      port_value: 9902
  • 启动命令
envoy -c envoy-demo.yaml --config-yaml "$(cat envoy-override.yaml)"

docker run --rm -it \
      -p 9902:9902 \
      -p 10000:10000 \
      envoyproxy/envoy:v1.35.3 \
          -c /etc/envoy/envoy.yaml \
          --config-yaml "$(cat envoy-override.yaml)"

启动服务

envoy -c envoy-demo.yaml

docker run --rm -it -d \
      -p 9901:9901 \
      -p 10000:10000 \
      envoyproxy/envoy:v1.35.3

# 调试,进入容器启动服务:`envoy -c /etc/envoy/envoy.yaml`
docker run --rm -it -d \
      -p 9901:9901 \
      -p 10000:10000 \
      --name envoy \
      --entrypoint bash \
      envoyproxy/envoy:v1.35.3

# 指定配置
docker run --rm -it \
      -v $(pwd)/envoy-custom.yaml:/envoy-custom.yaml \
      -p 9901:9901 \
      -p 10000:10000 \
      envoyproxy/envoy:v1.35.3 \
          -c /envoy-custom.yaml
本文总阅读量 次 本站总访问量 次 本站总访客数