envoy 學習筆記(二)之 安裝


一、在線安裝

官網地址:

    https://www.envoyproxy.io/docs/envoy/latest/

本案例 envoy 是安裝在虛擬機上,虛擬機的操作系統為:centos8

1、執行以下命令,通過 yum 進行安裝

yum install yum-utils
yum-config-manager --add-repo https://getenvoy.io/linux/centos/tetrate-getenvoy.repo
yum install getenvoy-envoy

 2、校驗安裝是否成功

envoy --vesion

 可以看到被默認安裝在了 /opt/getenvoy下,補充其它目錄,可以看到完整目錄結構如下:

3、啟動

(1) 配置簡單的 envoy.yaml   (envoy 啟動需要的配置文件)

static_resources:

  listeners:
  - name: listener_0
    address:
      socket_address:
        address: 0.0.0.0
        port_value: 10001     //listener 提供的對外的端口
    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.file
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
              path: /dev/stdout    //攔截的請求日志,這里配置輸出到控制台上
          http_filters:
          - name: envoy.filters.http.router   // route 過濾器
          route_config:    // 靜態路由配置,這里表示 10001 端口上的進入流量 "/" 被路由到集群 service_envoyproxy_io 上
            name: local_route
            virtual_hosts:
            - name: local_service
              domains: ["*"]
              routes:
              - match:
                  prefix: "/"
                route:
                  host_rewrite_literal: www.envoyproxy.io
                  cluster: service_envoyproxy_io

  clusters:
  - name: service_envoyproxy_io   //集群 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: 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:    //envoy 的管理服務
  access_log_path: logs/admin_envoy.log
  address:
    socket_address:
      address: 0.0.0.0
      port_value: 9901

(2) 在 控制台上執行啟動命令

cd /opt/getenvoy

envoy -c config/envoy.yaml --log-path logs/envoy.log -l trace

其中:

  •  --log-path 配置日志輸出地址
  • -l  配置日志等級

二、離線安裝

 待續


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM