Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting envoy configs to V2 #2957

Merged
merged 45 commits into from
Aug 16, 2018
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
ad4448d
This is initial work on migrating migrating envoy configs to v2.
Mar 31, 2018
d9f90f3
Updated yaml for envoy_service_to_service.template.json
Apr 5, 2018
de34d96
Fixed formatting issues for envoy_front_proxy
Apr 8, 2018
e4d8b82
fixed formatting for envoy_double_proxy
Apr 8, 2018
b123e1c
Fixed formatting for envoy_serive_to_service
Apr 9, 2018
86c86de
Added yaml file for access_log_helper
Apr 9, 2018
fc26c76
Fixed function name.(sorry for bad name)
Apr 10, 2018
70b6292
Updated double_proxy v2 template
Apr 14, 2018
5580ebd
Removed all old json files
Apr 19, 2018
d8b984b
Added converted google_com_proxy
Apr 20, 2018
a07ff79
Fixed extra spaces
Apr 20, 2018
05715ae
Added routing helper and router v2 template files.
Apr 21, 2018
fab0bee
Updated configgen with converted yaml templates
Apr 22, 2018
93186e1
Added intial work on converting envoy_service_to_service
Apr 25, 2018
4ebaf40
Minor changes to configgen.py until adding yaml as external dependency
Apr 26, 2018
2e22cc7
Added pyyaml external dependency
Apr 28, 2018
b35603e
Cleaned up envoy_front_config_v2.template
Apr 29, 2018
4f055dc
added envoy_service_service v2 template
May 3, 2018
e1bc087
fix for ci build and updated cds_config for service_to_service template
May 7, 2018
eff16f9
fix for ci build failure
May 15, 2018
aae77a5
Added tls context for front_proxy and double_proxy templates
May 17, 2018
e047376
Fixed build and updated envoy_front_proxy.v2.template
May 20, 2018
2fbdc9d
Adding router_helper config to envoy_front_proxy
May 20, 2018
e9093fc
Updated double proxy v2 template
May 21, 2018
2c9bb81
Updated initial work on service_to_service template
May 21, 2018
0d37bda
Added listener to service_to_service template
May 23, 2018
b346977
Updated ingress_listener function in service_to_service template.
May 23, 2018
c848ad4
Updated listeners in service_to_service template v2
May 24, 2018
d5e257c
Updates to envoy_front_proxy
May 26, 2018
4aceb54
updated merge conflict in new yaml and deleted json file for envoy_fr…
May 26, 2018
9b9f70a
Updates to envoy_double_proxy
May 28, 2018
e08f7d6
Changes to service_to_service template
May 29, 2018
f0b61d3
Removing old configs from config_validation server_test
May 29, 2018
d6284d8
Updated cluster configs in routing helper and internal_cluster_defini…
Jun 1, 2018
a3e5c5c
Updates to service_to_service
Jun 1, 2018
aaffc29
merge
Jun 1, 2018
44914c6
Old config files for google_com_proxy are not being
Jun 2, 2018
5ad8bbd
Merge remote-tracking branch 'upstream/master'
Jun 12, 2018
95f27b1
updated changes related to e6bf9f896c3ecfb1875a5bff53244ebfcd101a5a
Jun 12, 2018
affa303
Added comments from old template to double_proxy
Jun 17, 2018
96c1c64
Updates to front_proxy template
Jun 17, 2018
8f6ea92
updates after review.
Jun 19, 2018
840b101
Merge branch 'master' into master
srikailash Jun 26, 2018
b8e03c7
Updates from comparing yaml files with tool outputs
Aug 2, 2018
b9453ad
Updates
Aug 4, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions bazel/external/pyyaml.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
py_library(
name = "yaml",
srcs = glob(["lib/yaml/**/*.py"]),
imports = ["lib"],
visibility = ["//visibility:public"],
)
9 changes: 9 additions & 0 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ def _python_deps():
name = "jinja2",
actual = "@com_github_pallets_jinja//:jinja2",
)
_repository_impl(
name = "com_github_yaml_pyyaml",
build_file = "@envoy//bazel/external:pyyaml.BUILD",
)
native.bind(
name = "yaml",
actual = "@com_github_yaml_pyyaml//:yaml",
)


# Bazel native C++ dependencies. For the depedencies that doesn't provide autoconf/automake builds.
def _cc_deps():
Expand Down
4 changes: 4 additions & 0 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ REPOSITORY_LOCATIONS = dict(
commit = "f54b0e47a08782a6131cc3d60f94d038fa6e0a51", # v1.1.0
remote = "https://github.com/tencent/rapidjson",
),
com_github_yaml_pyyaml = dict(
commit = "b6cbfeec35e019734263a8f4e6a3340e94fe0a4f",
remote = "https://github.com/yaml/pyyaml",
),
com_google_googletest = dict(
commit = "43863938377a9ea1399c0596269e0890b5c5515a",
remote = "https://github.com/google/googletest",
Expand Down
7 changes: 5 additions & 2 deletions configs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ envoy_py_test_binary(
name = "configgen",
srcs = ["configgen.py"],
data = glob([
"*.json",
"*.yaml",
"*.json",
]),
external_deps = ["jinja2"],
external_deps = [
"jinja2",
"yaml",
],
)

filegroup(
Expand Down
15 changes: 0 additions & 15 deletions configs/access_log_format_helper.template.json

This file was deleted.

15 changes: 15 additions & 0 deletions configs/access_log_format_helper_v2.template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% macro ingress_sampled_log() -%}
format: "[%START_TIME%] \"%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH):256% %PROTOCOL%\" %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% \"%REQ(X-FORWARDED-FOR)%\" \"%REQ(USER-AGENT)%\" \"%REQ(X-REQUEST-ID)%\" \"%REQ(:AUTHORITY)%\"\n"
{% endmacro %}

{% macro ingress_full() -%}
format: "[%START_TIME%] \"%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%\" %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% \"%REQ(X-FORWARDED-FOR)%\" \"%REQ(USER-AGENT)%\" \"%REQ(X-REQUEST-ID)%\" \"%REQ(:AUTHORITY)%\"\n"
{% endmacro %}

{% macro egress_error_log() -%}
format: "[%START_TIME%] \"%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH):256% %PROTOCOL%\" %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% \"%REQ(X-FORWARDED-FOR)%\" \"%REQ(USER-AGENT)%\" \"%REQ(X-REQUEST-ID)%\" \"%REQ(:AUTHORITY)%\" \"%UPSTREAM_HOST%\"\n"
{% endmacro %}

{% macro egress_error_amazon_service() -%}
format: "[%START_TIME%] \"%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH):256% %PROTOCOL%\" %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% \"%REQ(X-FORWARDED-FOR)%\" \"%REQ(USER-AGENT)%\" \"%REQ(X-REQUEST-ID)%\" \"%REQ(:AUTHORITY)%\" \"%UPSTREAM_HOST%\" \"%RESP(X-AMZN-RequestId)%\"\n"
{% endmacro %}
38 changes: 21 additions & 17 deletions configs/configgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,15 @@
external_virtual_hosts = [
{
'name': 'dynamodb_iad',
'address': "tcp://127.0.0.1:9204",
'address': "127.0.0.1",
'protocol':"TCP",
'port_value':"9204",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: inconsistent spacing. let's run autopep8 over the python files to get a consistent format

'hosts': [
{
'name': 'dynamodb_iad', 'domain': '*',
'remote_address': 'dynamodb.us-east-1.amazonaws.com:443',
'remote_address': 'dynamodb.us-east-1.amazonaws.com',
'protocol': 'TCP',
'port_value': '443',
'verify_subject_alt_name': [ 'dynamodb.us-east-1.amazonaws.com' ],
'ssl': True
}
Expand All @@ -69,12 +73,14 @@
# as it demonstrates how to setup TCP proxy and the network rate limit filter.
mongos_servers = {
'somedb': {
'address': "tcp://127.0.0.1:27019",
'address': "127.0.0.1",
'protocol': "TCP",
'port_value': 27019,
'hosts': [
"router1.yourcompany.net:27817",
"router2.yourcompany.net:27817",
"router3.yourcompany.net:27817",
"router4.yourcompany.net:27817",
{'port_value' : 27817, 'address':'router1.yourcompany.net' , 'protocol': 'TCP'},
{'port_value' : 27817, 'address':'router2.yourcompany.net' , 'protocol': 'TCP'},
{'port_value' : 27817, 'address':'router3.yourcompany.net' , 'protocol': 'TCP'},
{'port_value' : 27817, 'address':'router4.yourcompany.net' , 'protocol': 'TCP'},
],
'ratelimit': True
}
Expand All @@ -85,20 +91,18 @@ def generate_config(template_path, template, output_file, **context):
env = jinja2.Environment(loader=jinja2.FileSystemLoader(template_path, followlinks=True),
undefined=jinja2.StrictUndefined)
raw_output = env.get_template(template).render(**context)
# Verify valid JSON and then dump it nicely formatted to avoid jinja pain.
output = json.loads(raw_output, object_pairs_hook=OrderedDict)
with open(output_file, 'w') as fh:
json.dump(output, fh, indent=2)
fh.write(raw_output)

# Generate a demo config for the main front proxy. This sets up both HTTP and HTTPS listeners,
# as well as a listener for the double proxy to connect to via SSL client authentication.
generate_config(SCRIPT_DIR, 'envoy_front_proxy.template.json',
'{}/envoy_front_proxy.json'.format(OUT_DIR), clusters=front_envoy_clusters)
generate_config(SCRIPT_DIR, 'envoy_front_proxy_v2.template.yaml',
'{}/envoy_front_proxy.v2.yaml'.format(OUT_DIR), clusters=front_envoy_clusters)

# Generate a demo config for the double proxy. This sets up both an HTTP and HTTPS listeners,
# and backhauls the traffic to the main front proxy.
generate_config(SCRIPT_DIR, 'envoy_double_proxy.template.json',
'{}/envoy_double_proxy.json'.format(OUT_DIR))
generate_config(SCRIPT_DIR, 'envoy_double_proxy_v2.template.yaml',
'{}/envoy_double_proxy.v2.yaml'.format(OUT_DIR))

# Generate a demo config for the service to service (local) proxy. This sets up several different
# listeners:
Expand All @@ -108,11 +112,11 @@ def generate_config(template_path, template, output_file, **context):
# optional external service ports: built from external_virtual_hosts above. Each external host
# that Envoy proxies to listens on its own port.
# optional mongo ports: built from mongos_servers above.
generate_config(SCRIPT_DIR, 'envoy_service_to_service.template.json',
'{}/envoy_service_to_service.json'.format(OUT_DIR),
generate_config(SCRIPT_DIR, 'envoy_service_to_service_v2.template.yaml',
'{}/envoy_service_to_service.yaml'.format(OUT_DIR),
internal_virtual_hosts=service_to_service_envoy_clusters,
external_virtual_hosts=external_virtual_hosts,
mongos_servers=mongos_servers)

for google_ext in ['json', 'yaml', 'v2.yaml']:
for google_ext in ['v2.yaml']:
shutil.copy(os.path.join(SCRIPT_DIR, 'google_com_proxy.%s' % google_ext), OUT_DIR)
152 changes: 0 additions & 152 deletions configs/envoy_double_proxy.template.json

This file was deleted.

Loading