Tuesday, October 27, 2020

Envoy in WSL

 First, go to ubuntu in wsl.

I have ubuntu-20.04 installed in wsl.

Following this installation instruction, it's pretty straight forward.

There is another instruction. I haven't try it yet.  

Download a demo configuration to try it.

Find the envoy-demo.yaml in here. This sample link to google site.

$envoy -c envoy-demo.yaml

Now, try to use proxy in the windows.

For a simple web page proxy :

listeners:

    - name: listener_page
      address:
        socket_address: { address: 0.0.0.0, port_value: 8102 }
      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_service3
                      domains: ["*"]
                      routes:
                        - match: { prefix: "/" }
                          route:
                            cluster: service_page
                http_filters:
                  - name: envoy.filters.http.router

clusters:

    - name: service_page
      connect_timeout: 0.25s
      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_page
        endpoints:
          - lb_endpoints:
              - endpoint:
                  address:
                    socket_address:
                      address: 172.29.144.1
                      port_value: 5000


 To look up the web server in the windows, the IP address is in /etc/resolv.conf

alex@alex-win:~/envoy$ ls -l
total 40
-rw-r--r-- 1 alex alex 7593 Oct 27 17:51 envoy-all.yaml
-rw-r--r-- 1 alex alex 1740 Oct 26 19:18 envoy-demo.yaml
-rw-r--r-- 1 alex alex  214 Oct 26 19:18 envoy-demo.yaml:Zone.Identifier
-rw-r--r-- 1 alex alex 1481 Oct 26 19:37 envoy-local-good.yaml
-rw-r--r-- 1 alex alex 1500 Oct 26 20:24 envoy-local.yaml
-rw-r--r-- 1 alex alex 2273 Oct 26 20:25 envoy-node.yaml
-rw-r--r-- 1 alex alex 6424 Oct 26 15:57 envoy.yaml
-rwxr-xr-x 1 alex alex   20 Oct 26 09:41 run.sh
alex@alex-win:~/envoy$ cat /etc/resolv.conf
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 172.29.144.1