docker run

1
2
3
4
5
6
7
docker run \
    -d -p 8080:8080 -p :9901 \
    --name envoy \
    --net mynet \
    --rm \
    -v ~/envoy/envoy.yaml:/etc/envoy/envoy.yaml \
    envoyproxy/envoy:v1.9.0

~/envoy/envoy.yaml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
admin:
  access_log_path: /tmp/admin_access.log
  address:
    socket_address: { address: 0.0.0.0, port_value: 9901 }
static_resources:
  listeners:
  - name: listener_0
    address:
      socket_address: { address: 0.0.0.0,  port_value: 8080 }
    filter_chains:
    - filters:
      - name: envoy.http_connection_manager
        config:
          stat_prefix: ingress_http
          http_filters:
          - name: envoy.router
          route_config:
            name: route
            virtual_hosts:
            - name: keycloak_service
              domains: ["*"]
              routes:
              - match:
                  prefix: "/"
                route:
                  cluster: keycloak_cluster
          access_log:
          - name: envoy.file_access_log
            config:
              path: /tmp/access.log
  clusters:
  - name: keycloak_cluster
    type: STRICT_DNS
    connect_timeout: 0.25s
    lb_policy: ROUND_ROBIN
    load_assignment:
      cluster_name: keycloak_cluster
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address: { address: keycloak-1, port_value: 8080 }
        - endpoint:
            address:
              socket_address: { address: keycloak-2, port_value: 8080 }

参考資料

https://i-beam.org/2019/02/03/envoy-static-load-balancer/