I want to do active health check for external services, below is my ServiceEntry
endpoints:
- address: testserver1.example.org
ports:
http: 8090
- address: testserver2.example.org
ports:
http: 9090
hosts:
- test.test-raja
ports:
- name: http
number: 80
protocol: http
- name: https
number: 443
protocol: https
resolution: DNS
and I created an EnvoyFilter to enable active health check:
configPatches:
- applyTo: CLUSTER
match:
cluster:
portNumber: 80
service: test.test-raja
context: GATEWAY
patch:
operation: MERGE
value:
health_checks:
- always_log_health_check_failures: true
codec_client_type: HTTP1
event_log_path: /dev/stdout
healthy_threshold: 10
http_health_check:
host: "test.test-raja"
path: /health
interval: 60s
no_traffic_healthy_interval: 60s
no_traffic_interval: 60s
timeout: 60s
unhealthy_threshold: 10
it works as expected, but one issue is that the host header of health check request is always test.raja-test
, I want to make it keep same with backend hostname, such as testserver1.example.org
.
There is a config in config-endpoint-v3-endpoint-healthcheckconfig to do that, and I can use EnvoyFilter
to set that hostname
, like below:
configPatches:
- applyTo: CLUSTER
match:
cluster:
portNumber: 80
service: test.test-raja
context: GATEWAY
patch:
operation: MERGE
value:
health_checks:
- always_log_health_check_failures: true
codec_client_type: HTTP1
event_log_path: /dev/stdout
healthy_threshold: 10
http_health_check:
path: /health
interval: 60s
no_traffic_healthy_interval: 60s
no_traffic_interval: 60s
timeout: 60s
unhealthy_threshold: 10
load_assignment: # this part is generated based on backend endpoints
cluster_name: outbound|80||test.test-raja
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: testserver1.example.org
port_value: 8090
health_check_config:
hostname: testserver1.example.org # set host here
load_balancing_weight: 1
metadata:
filter_metadata:
istio:
workload: ;;;;
- endpoint:
address:
socket_address:
address: testserver2.example.org
port_value: 9090
health_check_config:
hostname: testserver2.example.org # set host here
load_balancing_weight: 1
metadata:
filter_metadata:
istio:
workload: ;;;;
load_balancing_weight: 2
but this is not good enough since it almost override everything of the created ServiceEntry
.
Is there any istio style to do such things?
thanks!