Envoy快速开始

运行Envoy

本章节所执行的所有命令均在操作系统环境下执行

查看Envoy版本信息

[root@k3 ~]# envoy --version
envoy  version: d6a4496e712d7a2335b26e2f76210d5904002c26/1.17.1/clean-getenvoy-bb8060d-envoy/RELEASE/BoringSSL
[root@k3 ~]# 

查看Envoy命令行帮助信息

[root@k3 ~]# envoy --help

USAGE: 

   envoy  [--socket-mode <string>] [--socket-path <string>]
          [--disable-extensions <string>] [--cpuset-threads]
          [--enable-mutex-tracing] [--disable-hot-restart] [--mode
          <string>] [--parent-shutdown-time-s <uint32_t>] [--drain-strategy
          <string>] [--drain-time-s <uint32_t>] [--file-flush-interval-msec
          <uint32_t>] [--service-zone <string>] [--service-node <string>]
          [--service-cluster <string>] [--hot-restart-version]
          [--restart-epoch <uint32_t>] [--log-path <string>]
          [--enable-fine-grain-logging] [--log-format-escaped]
          [--log-format <string>] [--component-log-level <string>] [-l
          <string>] [--local-address-ip-version <string>]
          [--admin-address-path <string>] [--ignore-unknown-dynamic-fields]
          [--reject-unknown-dynamic-fields] [--allow-unknown-static-fields]
          [--allow-unknown-fields] [--bootstrap-version <string>]
          [--config-yaml <string>] [-c <string>] [--concurrency <uint32_t>]
          [--base-id-path <string>] [--use-dynamic-base-id] [--base-id
          <uint32_t>] [--] [--version] [-h]


Where: 

   --socket-mode <string>
     Socket file permission

   --socket-path <string>
     Path to hot restart socket file

   --disable-extensions <string>
     Comma-separated list of extensions to disable

   --cpuset-threads
     Get the default # of worker threads from cpuset size

   --enable-mutex-tracing
     Enable mutex contention tracing functionality

   --disable-hot-restart
     Disable hot restart functionality

   --mode <string>
     One of 'serve' (default; validate configs and then serve traffic
     normally) or 'validate' (validate configs and exit).

   --parent-shutdown-time-s <uint32_t>
     Hot restart parent shutdown time in seconds

   --drain-strategy <string>
     Hot restart drain sequence behaviour, one of 'gradual' (default) or
     'immediate'.

   --drain-time-s <uint32_t>
     Hot restart and LDS removal drain time in seconds

   --file-flush-interval-msec <uint32_t>
     Interval for log flushing in msec

   --service-zone <string>
     Zone name

   --service-node <string>
     Node name

   --service-cluster <string>
     Cluster name

   --hot-restart-version
     hot restart compatibility version

   --restart-epoch <uint32_t>
     hot restart epoch #

   --log-path <string>
     Path to logfile

   --enable-fine-grain-logging
     Logger mode: enable file level log control(Fancy Logger)or not

   --log-format-escaped
     Escape c-style escape sequences in the application logs

   --log-format <string>
     Log message format in spdlog syntax (see
     https://github.com/gabime/spdlog/wiki/3.-Custom-formatting)

     Default is "[%Y-%m-%d %T.%e][%t][%l][%n] [%g:%#] %v"

   --component-log-level <string>
     Comma separated list of component log levels. For example
     upstream:debug,config:trace

   -l <string>,  --log-level <string>
     Log levels: [trace][debug][info][warning
     |warn][error][critical][off]

     Default is [info]

   --local-address-ip-version <string>
     The local IP address version (v4 or v6).

   --admin-address-path <string>
     Admin address path

   --ignore-unknown-dynamic-fields
     ignore unknown fields in dynamic configuration

   --reject-unknown-dynamic-fields
     reject unknown fields in dynamic configuration

   --allow-unknown-static-fields
     allow unknown fields in static configuration

   --allow-unknown-fields
     allow unknown fields in static configuration (DEPRECATED)

   --bootstrap-version <string>
     API version to parse the bootstrap config as (e.g. 3). If unset, all
     known versions will be attempted

   --config-yaml <string>
     Inline YAML configuration, merges with the contents of --config-path

   -c <string>,  --config-path <string>
     Path to configuration file

   --concurrency <uint32_t>
     # of worker threads to run

   --base-id-path <string>
     path to which the base ID is written

   --use-dynamic-base-id
     the server chooses a base ID dynamically. Supersedes a static base ID.
     May not be used when the restart epoch is non-zero.

   --base-id <uint32_t>
     base ID so that multiple envoys can run on the same host if needed

   --,  --ignore_rest
     Ignores the rest of the labeled arguments following this flag.

   --version
     Displays version information and exits.

   -h,  --help
     Displays usage information and exits.


   envoy

[root@k3 ~]# 

运行一个demo配置

Envoy制定初始化配置文件参数 -c/–config-path
[root@k3 ~]# envoy -c new_demo.yaml
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:323] initializing epoch 0 (base id=0, hot restart version=11.104)
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:325] statically linked extensions:
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.dubbo_proxy.route_matchers: default
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.filters.udp_listener: envoy.filters.udp.dns_filter, envoy.filters.udp_listener.udp_proxy
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.compression.compressor: envoy.compression.gzip.compressor
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.transport_sockets.downstream: envoy.transport_sockets.alts, envoy.transport_sockets.quic, envoy.transport_sockets.raw_buffer, envoy.transport_sockets.starttls, envoy.transport_sockets.tap, envoy.transport_sockets.tls, raw_buffer, starttls, tls
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.thrift_proxy.filters: envoy.filters.thrift.rate_limit, envoy.filters.thrift.router
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.thrift_proxy.transports: auto, framed, header, unframed
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.stats_sinks: envoy.dog_statsd, envoy.metrics_service, envoy.stat_sinks.dog_statsd, envoy.stat_sinks.hystrix, envoy.stat_sinks.metrics_service, envoy.stat_sinks.statsd, envoy.stat_sinks.wasm, envoy.statsd
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.thrift_proxy.protocols: auto, binary, binary/non-strict, compact, twitter
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.dubbo_proxy.protocols: dubbo
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.dubbo_proxy.filters: envoy.filters.dubbo.router
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.upstreams: envoy.filters.connection_pools.tcp.generic
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.upstream_options: envoy.extensions.upstreams.http.v3.HttpProtocolOptions, envoy.upstreams.http.http_protocol_options
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.udp_listeners: quiche_quic_listener, raw_udp_listener
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.filters.network: envoy.client_ssl_auth, envoy.echo, envoy.ext_authz, envoy.filters.network.client_ssl_auth, envoy.filters.network.direct_response, envoy.filters.network.dubbo_proxy, envoy.filters.network.echo, envoy.filters.network.ext_authz, envoy.filters.network.http_connection_manager, envoy.filters.network.kafka_broker, envoy.filters.network.local_ratelimit, envoy.filters.network.mongo_proxy, envoy.filters.network.mysql_proxy, envoy.filters.network.postgres_proxy, envoy.filters.network.ratelimit, envoy.filters.network.rbac, envoy.filters.network.redis_proxy, envoy.filters.network.rocketmq_proxy, envoy.filters.network.sni_cluster, envoy.filters.network.sni_dynamic_forward_proxy, envoy.filters.network.tcp_proxy, envoy.filters.network.thrift_proxy, envoy.filters.network.wasm, envoy.filters.network.zookeeper_proxy, envoy.http_connection_manager, envoy.mongo_proxy, envoy.ratelimit, envoy.redis_proxy, envoy.tcp_proxy
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.resource_monitors: envoy.resource_monitors.fixed_heap, envoy.resource_monitors.injected_resource
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.grpc_credentials: envoy.grpc_credentials.aws_iam, envoy.grpc_credentials.default, envoy.grpc_credentials.file_based_metadata
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.internal_redirect_predicates: envoy.internal_redirect_predicates.allow_listed_routes, envoy.internal_redirect_predicates.previous_routes, envoy.internal_redirect_predicates.safe_cross_scheme
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.clusters: envoy.cluster.eds, envoy.cluster.logical_dns, envoy.cluster.original_dst, envoy.cluster.static, envoy.cluster.strict_dns, envoy.clusters.aggregate, envoy.clusters.dynamic_forward_proxy, envoy.clusters.redis
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.retry_host_predicates: envoy.retry_host_predicates.omit_canary_hosts, envoy.retry_host_predicates.omit_host_metadata, envoy.retry_host_predicates.previous_hosts
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.retry_priorities: envoy.retry_priorities.previous_priorities
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.dubbo_proxy.serializers: dubbo.hessian2
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.http.cache: envoy.extensions.http.cache.simple
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.wasm.runtime: envoy.wasm.runtime.null, envoy.wasm.runtime.v8
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.filters.listener: envoy.filters.listener.http_inspector, envoy.filters.listener.original_dst, envoy.filters.listener.original_src, envoy.filters.listener.proxy_protocol, envoy.filters.listener.tls_inspector, envoy.listener.http_inspector, envoy.listener.original_dst, envoy.listener.original_src, envoy.listener.proxy_protocol, envoy.listener.tls_inspector
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.udp_packet_writers: udp_default_writer, udp_gso_batch_writer
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.guarddog_actions: envoy.watchdog.abort_action, envoy.watchdog.profile_action
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.compression.decompressor: envoy.compression.gzip.decompressor
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.quic_server_codec: quiche
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.filters.http: envoy.buffer, envoy.cors, envoy.csrf, envoy.ext_authz, envoy.ext_proc, envoy.fault, envoy.filters.http.adaptive_concurrency, envoy.filters.http.admission_control, envoy.filters.http.aws_lambda, envoy.filters.http.aws_request_signing, envoy.filters.http.buffer, envoy.filters.http.cache, envoy.filters.http.cdn_loop, envoy.filters.http.compressor, envoy.filters.http.cors, envoy.filters.http.csrf, envoy.filters.http.decompressor, envoy.filters.http.dynamic_forward_proxy, envoy.filters.http.dynamo, envoy.filters.http.ext_authz, envoy.filters.http.ext_proc, envoy.filters.http.fault, envoy.filters.http.grpc_http1_bridge, envoy.filters.http.grpc_http1_reverse_bridge, envoy.filters.http.grpc_json_transcoder, envoy.filters.http.grpc_stats, envoy.filters.http.grpc_web, envoy.filters.http.gzip, envoy.filters.http.header_to_metadata, envoy.filters.http.health_check, envoy.filters.http.ip_tagging, envoy.filters.http.jwt_authn, envoy.filters.http.local_ratelimit, envoy.filters.http.lua, envoy.filters.http.oauth2, envoy.filters.http.on_demand, envoy.filters.http.original_src, envoy.filters.http.ratelimit, envoy.filters.http.rbac, envoy.filters.http.router, envoy.filters.http.squash, envoy.filters.http.tap, envoy.filters.http.wasm, envoy.grpc_http1_bridge, envoy.grpc_json_transcoder, envoy.grpc_web, envoy.gzip, envoy.health_check, envoy.http_dynamo_filter, envoy.ip_tagging, envoy.local_rate_limit, envoy.lua, envoy.rate_limit, envoy.router, envoy.squash
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.transport_sockets.upstream: envoy.transport_sockets.alts, envoy.transport_sockets.quic, envoy.transport_sockets.raw_buffer, envoy.transport_sockets.tap, envoy.transport_sockets.tls, envoy.transport_sockets.upstream_proxy_protocol, raw_buffer, tls
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.health_checkers: envoy.health_checkers.redis
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.access_loggers: envoy.access_loggers.file, envoy.access_loggers.http_grpc, envoy.access_loggers.tcp_grpc, envoy.access_loggers.wasm, envoy.file_access_log, envoy.http_grpc_access_log, envoy.tcp_grpc_access_log, envoy.wasm_access_log
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.rate_limit_descriptors: envoy.rate_limit_descriptors.expr
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.quic_client_codec: quiche
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.bootstrap: envoy.bootstrap.wasm, envoy.extensions.network.socket_interface.default_socket_interface
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.resolvers: envoy.ip
[2021-03-31 23:15:43.980][140288][info][main] [external/envoy/source/server/server.cc:327]   envoy.tracers: envoy.dynamic.ot, envoy.lightstep, envoy.tracers.datadog, envoy.tracers.dynamic_ot, envoy.tracers.lightstep, envoy.tracers.opencensus, envoy.tracers.skywalking, envoy.tracers.xray, envoy.tracers.zipkin, envoy.zipkin
[2021-03-31 23:15:43.991][140288][info][main] [external/envoy/source/server/server.cc:343] HTTP header map info:
[2021-03-31 23:15:43.992][140288][warning][runtime] [external/envoy/source/common/runtime/runtime_features.cc:31] Unable to use runtime singleton for feature envoy.http.headermap.lazy_map_min_size
[2021-03-31 23:15:43.992][140288][warning][runtime] [external/envoy/source/common/runtime/runtime_features.cc:31] Unable to use runtime singleton for feature envoy.http.headermap.lazy_map_min_size
[2021-03-31 23:15:43.993][140288][warning][runtime] [external/envoy/source/common/runtime/runtime_features.cc:31] Unable to use runtime singleton for feature envoy.http.headermap.lazy_map_min_size
[2021-03-31 23:15:43.993][140288][warning][runtime] [external/envoy/source/common/runtime/runtime_features.cc:31] Unable to use runtime singleton for feature envoy.http.headermap.lazy_map_min_size
[2021-03-31 23:15:43.993][140288][info][main] [external/envoy/source/server/server.cc:346]   request header map: 616 bytes: :authority,:method,:path,:protocol,:scheme,accept,accept-encoding,access-control-request-method,authentication,authorization,cache-control,cdn-loop,connection,content-encoding,content-length,content-type,expect,grpc-accept-encoding,grpc-timeout,if-match,if-modified-since,if-none-match,if-range,if-unmodified-since,keep-alive,origin,pragma,proxy-connection,referer,te,transfer-encoding,upgrade,user-agent,via,x-client-trace-id,x-envoy-attempt-count,x-envoy-decorator-operation,x-envoy-downstream-service-cluster,x-envoy-downstream-service-node,x-envoy-expected-rq-timeout-ms,x-envoy-external-address,x-envoy-force-trace,x-envoy-hedge-on-per-try-timeout,x-envoy-internal,x-envoy-ip-tags,x-envoy-max-retries,x-envoy-original-path,x-envoy-original-url,x-envoy-retriable-header-names,x-envoy-retriable-status-codes,x-envoy-retry-grpc-on,x-envoy-retry-on,x-envoy-upstream-alt-stat-name,x-envoy-upstream-rq-per-try-timeout-ms,x-envoy-upstream-rq-timeout-alt-response,x-envoy-upstream-rq-timeout-ms,x-forwarded-client-cert,x-forwarded-for,x-forwarded-proto,x-ot-span-context,x-request-id
[2021-03-31 23:15:43.993][140288][info][main] [external/envoy/source/server/server.cc:346]   request trailer map: 128 bytes: 
[2021-03-31 23:15:43.993][140288][info][main] [external/envoy/source/server/server.cc:346]   response header map: 424 bytes: :status,access-control-allow-credentials,access-control-allow-headers,access-control-allow-methods,access-control-allow-origin,access-control-expose-headers,access-control-max-age,age,cache-control,connection,content-encoding,content-length,content-type,date,etag,expires,grpc-message,grpc-status,keep-alive,last-modified,location,proxy-connection,server,transfer-encoding,upgrade,vary,via,x-envoy-attempt-count,x-envoy-decorator-operation,x-envoy-degraded,x-envoy-immediate-health-check-fail,x-envoy-ratelimited,x-envoy-upstream-canary,x-envoy-upstream-healthchecked-cluster,x-envoy-upstream-service-time,x-request-id
[2021-03-31 23:15:43.993][140288][info][main] [external/envoy/source/server/server.cc:346]   response trailer map: 152 bytes: grpc-message,grpc-status
[2021-03-31 23:15:43.994][140288][info][main] [external/envoy/source/server/server.cc:486] admin address: 0.0.0.0:9901
[2021-03-31 23:15:43.996][140288][info][main] [external/envoy/source/server/server.cc:634] runtime: layers:
  - name: base
    static_layer:
      {}
  - name: admin
    admin_layer:
      {}
[2021-03-31 23:15:43.996][140288][info][config] [external/envoy/source/server/configuration_impl.cc:125] loading tracing configuration
[2021-03-31 23:15:43.996][140288][info][config] [external/envoy/source/server/configuration_impl.cc:85] loading 0 static secret(s)
[2021-03-31 23:15:43.996][140288][info][config] [external/envoy/source/server/configuration_impl.cc:91] loading 1 cluster(s)
[2021-03-31 23:15:44.000][140288][info][config] [external/envoy/source/server/configuration_impl.cc:95] loading 1 listener(s)
[2021-03-31 23:15:44.007][140288][info][config] [external/envoy/source/server/configuration_impl.cc:107] loading stats configuration
[2021-03-31 23:15:44.009][140288][info][main] [external/envoy/source/server/server.cc:731] starting main dispatch loop
[2021-03-31 23:15:44.015][140288][info][runtime] [external/envoy/source/common/runtime/runtime_impl.cc:425] RTDS has finished initialization
[2021-03-31 23:15:44.015][140288][info][upstream] [external/envoy/source/common/upstream/cluster_manager_impl.cc:191] cm init: all clusters initialized
[2021-03-31 23:15:44.015][140288][info][main] [external/envoy/source/server/server.cc:712] all clusters initialized. initializing init manager
[2021-03-31 23:15:44.015][140288][info][config] [external/envoy/source/server/listener_manager_impl.cc:888] all dependencies initialized. starting workers
[2021-03-31 23:15:44.016][140288][warning][main] [external/envoy/source/server/server.cc:609] there is no configured limit to the number of allowed active connections. Set a limit via the runtime key overload.global_downstream_max_connections


envoy-demo.yaml文件内容

static_resources:

  listeners:
  - name: listener_0
    address:
      socket_address:
        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
          stat_prefix: ingress_http
          access_log:
          - name: envoy.access_loggers.stdout
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
              path: /dev/stdout
          http_filters:
          - name: envoy.filters.http.router
          route_config:
            name: local_route
            virtual_hosts:
            - name: local_service
              domains: ["*"]
              routes:
              - match:
                  prefix: "/"
                route:
                  host_rewrite_literal: 10.50.10.210
                  cluster: service_envoyproxy_io

  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
    load_assignment:
      cluster_name: service_envoyproxy_io
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: 10.50.10.210
                port_value: 30595
   # transport_socket:
   #   name: envoy.transport_sockets.tls
   #   typed_config:
   #     "@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
   #     sni: www.baidu.com

admin:
  address:
    socket_address:
      address: 0.0.0.0
      port_value: 9901
  access_log_path: /dev/stdout



查看执行效果

在这里插入图片描述

查看管理控制台

在这里插入图片描述

日志

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值