我正在kubernetizing(如果可以使用该术语),this演示,并且从前台服务获得了503。
因此,我要做的是创建三个服务;绿色,蓝色和红色,并且一切正常。如果我直接打他们,我得到200,但是当我通过前台服务时,我得到503。
该演示的想法是获得一项前台服务,然后根据路径将请求转发给后面的一项服务(绿色,蓝色或红色)。这是前台服务特使yaml文件:
static_resources:
listeners:
- address:
socket_address:
address: 0.0.0.0
port_value: 80
filter_chains:
- filters:
- name: envoy.http_connection_manager
config:
codec_type: auto
stat_prefix: ingress_http
route_config:
name: local_route
virtual_hosts:
- name: backend
domains:
- "*"
routes:
- match:
prefix: "/service/blue"
route:
cluster: service_blue
- match:
prefix: "/service/green"
route:
cluster: service_green
- match:
prefix: "/service/red"
route:
cluster: service_red
http_filters:
- name: envoy.router
config: {}
clusters:
- name: service_blue
connect_timeout: 0.25s
type: strict_dns
lb_policy: round_robin
http2_protocol_options: {}
hosts:
- socket_address:
address: blue
port_value: 80
- name: service_green
connect_timeout: 0.25s
type: strict_dns
lb_policy: round_robin
http2_protocol_options: {}
hosts:
- socket_address:
address: green
port_value: 80
- name: service_red
connect_timeout: 0.25s
type: strict_dns
lb_policy: round_robin
http2_protocol_options: {}
hosts:
- socket_address:
address: red
port_value: 80
admin:
access_log_path: "/dev/null"
address:
socket_address:
address: 0.0.0.0
port_value: 8001
这些是我在集群中的服务:
# kubectl get svc -n envoy-demo
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
blue ClusterIP 10.98.101.176 <none> 80/TCP 5h31m
front ClusterIP 10.98.119.222 <none> 80/TCP 73m
green ClusterIP 10.107.136.62 <none> 80/TCP 54m
red ClusterIP 10.101.240.162 <none> 80/TCP 160m
如果我访问front
pod并卷曲任何服务,我将得到200:
root@envoy-front-54856466dc-59jdw:/# curl blue/service/blue -I
HTTP/1.0 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 166
Server: Werkzeug/0.16.0 Python/3.7.4
Date: Mon, 14 Oct 2019 15:53:14 GMT
root@envoy-front-54856466dc-59jdw:/# curl green/service/green -I
HTTP/1.0 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 170
Server: Werkzeug/0.16.0 Python/3.7.4
Date: Mon, 14 Oct 2019 15:53:31 GMT
root@envoy-front-54856466dc-59jdw:/# curl red/service/red -I
HTTP/1.0 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 163
Server: Werkzeug/0.16.0 Python/3.7.4
Date: Mon, 14 Oct 2019 15:53:38 GMT
这些服务实际上在/service/whatever
上返回200。
如果我卷曲到本地主机,或者从pod外部转到front
服务,则会得到503:
# curl localhost/service/red
upstream connect error or disconnect/reset before headers. reset reason: connection termination
同样,如果我从front
窗格外部卷曲front
服务的IP和服务名称。
理想情况下,该服务正在运行:
# netstat -tlpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8001 0.0.0.0:* LISTEN 6/envoy
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 6/envoy
这很重要,这是服务特使yaml文件:
static_resources:
listeners:
- address:
socket_address:
address: 0.0.0.0
port_value: 80
filter_chains:
- filters:
- name: envoy.http_connection_manager
config:
codec_type: auto
stat_prefix: ingress_http
route_config:
name: local_route
virtual_hosts:
- name: service
domains:
- "*"
routes:
- match:
prefix: "/service"
route:
cluster: local_service
http_filters:
- name: envoy.router
config: {}
clusters:
- name: local_service
connect_timeout: 0.25s
type: strict_dns
lb_policy: round_robin
hosts:
- socket_address:
address: 0.0.0.0
port_value: 8080
admin:
access_log_path: "/dev/null"
address:
socket_address:
address: 0.0.0.0
port_value: 8081
所有服务都非常相似;其中一项是正常服务,另一项增加了延迟,另一项中止了50%的请求。
有什么主意我在做错什么吗?