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

ROX-21779 Add envoy active listener #1602

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Changes from all commits
Commits
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
146 changes: 72 additions & 74 deletions templates/service-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -859,87 +859,15 @@ objects:
address: 0.0.0.0
port_value: 9001
listener_filters:
- name: tls_inspector
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TLS inspector was also added to perform SNI-based routing. No longer needed

typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.listener.tls_inspector.v3.TlsInspector
filter_chains:
- filter_chain_match:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This whole filter chain was an attempt at using sni-based certificate selection, which doesn't work with openshift ingress

server_names:
- "fleet-manager-active"
- "fleet-manager-active.${NAMESPACE}"
- "fleet-manager-active.${NAMESPACE}.svc"
- "fleet-manager-active.${NAMESPACE}.svc.cluster"
- "fleet-manager-active.${NAMESPACE}.svc.cluster.local"
- "romndkjdq62p7sr.api.integration.openshift.com"
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.DownstreamTlsContext
full_scan_certs_on_sni_mismatch: true
common_tls_context:
tls_certificates:
- certificate_chain: {filename: "/secrets/active-tls/tls.crt"}
private_key: {filename: "/secrets/active-tls/tls.key"}
- certificate_chain: {filename: "/secrets/active-tls/tls.crt"}
private_key: {filename: "/secrets/active-tls/tls.key"}
filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
access_log:
- name: envoy.access_loggers.file
typed_config:
"@type": type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
path: /dev/stdout
stat_prefix: ingress
route_config:
name: backend
virtual_hosts:
- name: all
domains:
- "*"
routes:
- name: default
match:
prefix: /
route:
cluster: backend
# Add security headers.
typed_per_filter_config:
lua_security_headers:
"@type": type.googleapis.com/envoy.extensions.filters.http.lua.v3.LuaPerRoute
source_code:
inline_string: |
function envoy_on_response(response_handle)
contentSecurityPolicy = "default-src 'none'; script-src 'self'; img-src 'self'; style-src 'self'; connect-src 'self'";
response_handle:headers():add("Content-Security-Policy", contentSecurityPolicy);
response_handle:headers():add("X-Frame-Options", "deny");
response_handle:headers():add("X-XSS-Protection", "1; mode=block");
response_handle:headers():add("X-Content-Type-Options", "nosniff");
response_handle:headers():add("Referrer-Policy", "no-referrer");
response_handle:headers():add("X-Download-Options", "noopen");
response_handle:headers():add("X-DNS-Prefetch-Control", "off");
response_handle:headers():add("Strict-Transport-Security", "max-age=31536000; includeSubDomains");
end
http_filters:
- name: lua_security_headers
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router

- transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.DownstreamTlsContext
full_scan_certs_on_sni_mismatch: true
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was added to try selecting the proper certificate

common_tls_context:
tls_certificates:
- certificate_chain: {filename: "/secrets/tls/tls.crt"}
private_key: {filename: "/secrets/tls/tls.key"}
- certificate_chain: {filename: "/secrets/active-tls/tls.crt"}
private_key: {filename: "/secrets/active-tls/tls.key"}
Comment on lines -941 to -942
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This listener doesn't use this certificate, it was added to try resolving the correct cert

filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
Expand Down Expand Up @@ -1060,6 +988,73 @@ objects:
# code: "CENTRALS-MGMT-429"
# reason: "Too Many Requests"

# We need a second listener on a different port, because the openshift ingress does
# not forward SNI headers, and envoy is not able to determine which certificate to use
# for TLS termination. So we need a whole new listener with a different port.
# This has the same config as the 9001 listener, but listens on port 9002 and uses
# the fleet-manager-active.<ns>.svc certificate.
- name: ingress-active
address:
socket_address:
address: 0.0.0.0
port_value: 9002
listener_filters:
filter_chains:
- transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.DownstreamTlsContext
common_tls_context:
tls_certificates:
- certificate_chain: {filename: "/secrets/active-tls/tls.crt"}
private_key: {filename: "/secrets/active-tls/tls.key"}
filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
access_log:
- name: envoy.access_loggers.file
typed_config:
"@type": type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
path: /dev/stdout
stat_prefix: ingress
route_config:
name: backend
virtual_hosts:
- name: all
domains:
- "*"
routes:
- name: default
match:
prefix: /
route:
cluster: backend
# Add security headers.
typed_per_filter_config:
lua_security_headers:
"@type": type.googleapis.com/envoy.extensions.filters.http.lua.v3.LuaPerRoute
source_code:
inline_string: |
function envoy_on_response(response_handle)
contentSecurityPolicy = "default-src 'none'; script-src 'self'; img-src 'self'; style-src 'self'; connect-src 'self'";
response_handle:headers():add("Content-Security-Policy", contentSecurityPolicy);
response_handle:headers():add("X-Frame-Options", "deny");
response_handle:headers():add("X-XSS-Protection", "1; mode=block");
response_handle:headers():add("X-Content-Type-Options", "nosniff");
response_handle:headers():add("Referrer-Policy", "no-referrer");
response_handle:headers():add("X-Download-Options", "noopen");
response_handle:headers():add("X-DNS-Prefetch-Control", "off");
response_handle:headers():add("Strict-Transport-Security", "max-age=31536000; includeSubDomains");
end
http_filters:
- name: lua_security_headers
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router

- kind: Deployment
apiVersion: apps/v1
metadata:
Expand Down Expand Up @@ -1409,6 +1404,9 @@ objects:
- name: api-envoy
protocol: TCP
containerPort: 9001
- name: api-envoy-active
protocol: TCP
containerPort: 9002
- name: metrics-envoy
protocol: TCP
containerPort: 9000
Expand Down Expand Up @@ -1508,8 +1506,8 @@ objects:
app: fleet-manager
fleet-manager-active: "true"
ports:
- port: 9001
targetPort: 9001
- port: 9002
targetPort: 9002
protocol: TCP

# Services for diagnostic ports (not part of main service because we
Expand Down