Skip to content

Commit ee7cf8e

Browse files
committed
Use HealthCheck filter for readiness probe
Signed-off-by: Tero Saarni <[email protected]>
1 parent 8d54596 commit ee7cf8e

File tree

1 file changed

+45
-18
lines changed

1 file changed

+45
-18
lines changed

internal/envoy/v3/stats.go

+45-18
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
envoy_config_core_v3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
1818
envoy_config_listener_v3 "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3"
1919
envoy_config_route_v3 "github.com/envoyproxy/go-control-plane/envoy/config/route/v3"
20+
envoy_filter_http_health_check_v3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/health_check/v3"
2021
envoy_filter_http_router_v3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/router/v3"
2122
envoy_filter_network_http_connection_manager_v3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3"
2223
envoy_transport_socket_tls_v3 "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/tls/v3"
@@ -117,25 +118,51 @@ func AdminListener(port int) *envoy_config_listener_v3.Listener {
117118

118119
// filterChain returns a filter chain used by static listeners.
119120
func filterChain(statsPrefix string, transportSocket *envoy_config_core_v3.TransportSocket, routes *envoy_filter_network_http_connection_manager_v3.HttpConnectionManager_RouteConfig) []*envoy_config_listener_v3.FilterChain {
120-
return []*envoy_config_listener_v3.FilterChain{{
121-
Filters: []*envoy_config_listener_v3.Filter{{
122-
Name: wellknown.HTTPConnectionManager,
123-
ConfigType: &envoy_config_listener_v3.Filter_TypedConfig{
124-
TypedConfig: protobuf.MustMarshalAny(&envoy_filter_network_http_connection_manager_v3.HttpConnectionManager{
125-
StatPrefix: statsPrefix,
126-
RouteSpecifier: routes,
127-
HttpFilters: []*envoy_filter_network_http_connection_manager_v3.HttpFilter{{
128-
Name: wellknown.Router,
129-
ConfigType: &envoy_filter_network_http_connection_manager_v3.HttpFilter_TypedConfig{
130-
TypedConfig: protobuf.MustMarshalAny(&envoy_filter_http_router_v3.Router{}),
131-
},
132-
}},
133-
NormalizePath: wrapperspb.Bool(true),
134-
}),
121+
return []*envoy_config_listener_v3.FilterChain{
122+
{
123+
Filters: []*envoy_config_listener_v3.Filter{
124+
{
125+
Name: wellknown.HTTPConnectionManager,
126+
ConfigType: &envoy_config_listener_v3.Filter_TypedConfig{
127+
TypedConfig: protobuf.MustMarshalAny(&envoy_filter_network_http_connection_manager_v3.HttpConnectionManager{
128+
StatPrefix: statsPrefix,
129+
RouteSpecifier: routes,
130+
HttpFilters: []*envoy_filter_network_http_connection_manager_v3.HttpFilter{
131+
{
132+
Name: wellknown.HealthCheck,
133+
ConfigType: &envoy_filter_network_http_connection_manager_v3.HttpFilter_TypedConfig{
134+
TypedConfig: protobuf.MustMarshalAny(&envoy_filter_http_health_check_v3.HealthCheck{
135+
PassThroughMode: wrapperspb.Bool(false),
136+
Headers: []*envoy_config_route_v3.HeaderMatcher{
137+
{
138+
Name: ":path",
139+
HeaderMatchSpecifier: &envoy_config_route_v3.HeaderMatcher_StringMatch{
140+
StringMatch: &envoy_matcher_v3.StringMatcher{
141+
MatchPattern: &envoy_matcher_v3.StringMatcher_Exact{
142+
Exact: "/ready",
143+
},
144+
},
145+
},
146+
},
147+
},
148+
}),
149+
},
150+
},
151+
{
152+
Name: wellknown.Router,
153+
ConfigType: &envoy_filter_network_http_connection_manager_v3.HttpFilter_TypedConfig{
154+
TypedConfig: protobuf.MustMarshalAny(&envoy_filter_http_router_v3.Router{}),
155+
},
156+
},
157+
},
158+
NormalizePath: wrapperspb.Bool(true),
159+
}),
160+
},
161+
},
135162
},
136-
}},
137-
TransportSocket: transportSocket,
138-
}}
163+
TransportSocket: transportSocket,
164+
},
165+
}
139166
}
140167

141168
// routeForAdminInterface creates static RouteConfig that forwards requested paths to Envoy admin interface.

0 commit comments

Comments
 (0)