问题描述
我正在为 Istio + gRPC 开发 POC,Istio 版本是 1.6,但我看不到任何 gRPC 流量到我的 Pod。
我怀疑我的 Istio 网关或 VirtualService 遗漏了什么,但我不知道这里出了什么问题?有人可以帮我检查我的 yaml 文件并纠正我的 yaml 中的缺失或错误吗?
apiVersion: apps/v1
kind: Deployment
Metadata:
labels:
app: syslogserver
name: syslogserver
namespace: mynamespace
spec:
selector:
matchLabels:
app: syslogserver
replicas: 1
template:
Metadata:
labels:
app: syslogserver
spec:
containers:
- name: syslogserver
image: docker.io/grpc-syslog:latest
imagePullPolicy: Always
ports:
- containerPort: 5555
imagePullSecrets:
- name: pull-image-credential
---
apiVersion: v1
kind: Service
Metadata:
name: syslogserver
namespace: mynamespace
labels:
app: syslogserver
spec:
selector:
app: syslogserver
ports:
- name: grpc
port: 6666
protocol: TCP
targetPort: 5555
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
Metadata:
name: xyz-ingress-gateway
namespace: istio-system
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 7777
name: http2
protocol: HTTP2
hosts:
- "*"
---
apiVersion: v1
kind: Service
Metadata:
name: xyz-istio-ingressgateway
namespace: istio-system
labels:
app: xyz-istio-ingressgateway
spec:
selector:
app: istio-ingressgateway
istio: ingressgateway
type: NodePort
ports:
- protocol: TCP
nodePort: 32555
port: 7777
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
Metadata:
name: xyz-ingress-gateway-virtualservice
namespace: istio-system
spec:
hosts:
- "*"
gateways:
- xyz-ingress-gateway
#tls:
http:
- match:
- port: 7777
route:
- destination:
host: syslogserver.mynamespace.svc.cluster.local
port:
number: 6666
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
Metadata:
name: xyz-destinationrule
namespace: istio-system
spec:
host: syslogserver.mynamespace.svc.cluster.local
trafficPolicy:
loadBalancer:
simple: ROUND_ROBIN
请多多指教,谢谢。
解决方法
从我看来,服务 name: xyz-istio-ingressgateway
应该被删除,因为这不是您在使用 Istio 时的通信方式。
相反,您应该使用 istio ingress gateway,结合网关、虚拟服务和目标规则。
如果您在网关上选择了端口号 7777,则必须在 istio 入口网关上打开此端口,在此 stackoverflow question 中几乎没有方法可以做到这一点。 There 是默认的 istio 入口网关值。
配置端口后,您可以使用 kubectl get svc istio-ingressgateway -n istio-system
获取 istio Ingress 网关的外部 IP。
如果设置了外部 IP 值,则您的环境具有可用于入口网关的外部负载平衡器。如果 EXTERNAL-IP 值处于待定状态,则您的环境不会为入口网关提供外部负载均衡器。在这种情况下,您可以使用服务的节点端口访问网关。
你的其余配置对我来说看起来不错。只是提醒一下 injecting 您的 Pod 的 sidecar 代理。