0

我已经关注了使用外部 HTTPS 代理的整个主题,指出它是基于 VIP 的示例,而不是 k8s 服务方法。但在我的情况下,Squid 可以通过 k8s 服务访问,我想使用 FQDN 而不是 VIP 地址。

我已经更改了配置删除addresses部分:

Squid Istio 服务入口:

apiVersion: networking.istio.io/v1beta1
kind: ServiceEntry
metadata:
  name: proxy
spec:
  hosts:
  - squid.external.svc.cluster.local
  location: MESH_EXTERNAL
  exportTo: 
  - "."
  ports:
  - number: 3128
    name: tcp
    protocol: TCP

externalns中的网格外部 Squid 部件:

鱿鱼荚:

  ports:
  - containerPort: 3128
    name: http
    protocol: TCP

鱿鱼k8s服务:

  ports:
  - name: http
    port: 3128
    protocol: TCP
    targetPort: http

来自硬币的冰壶sleep

HTTPS_PROXY=http://squid.external:3128 curl https://en.wikipedia.org/wiki/Main_Page

在 sleep sidecar 上给出结果:

[2021-07-21T06:46:23.938Z] "CONNECT - HTTP/1.1" 404 NR route_not_found - "-" 0 0 0 - "-" "curl/7.77.0-DEV" "424a0870-af92-4a59-a3af-c8dc91b31512" "en.wikipedia.org:443" "-" - - 192.168.101.185:3128 10.10.2.8:39744 - -

其中 192.168.101.185 是 squid 服务 IP。

Envoy 报错说没有路由,但是找到了服务。缺少什么,出了什么问题?我感谢任何帮助或建议。

4

1 回答 1

0

我一直在努力解决这个问题,直到找到CONNECT - HTTP/1.1" 404 NR route_not_found。最后我通过绕过 istio sidecar 解决了这个问题,因为我在 SQUID 端口上的出站流量:

带有 istio sidecar 的示例代理客户端 POD:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: deb
spec:
  replicas: 1
  selector:
    matchLabels:
      app: deb
  template:
    metadata:
      labels:
        app: deb
      annotations: 
        traffic.sidecar.istio.io/excludeOutboundPorts: '3128' # A comma separated list of outbound ports to be excluded from redirection to Envoy.
    spec:
      terminationGracePeriodSeconds: 0
      containers:
      - name: debian
        image: debian:buster
        command: ["/bin/sleep", "3650d"]
        imagePullPolicy: IfNotPresent

现在我可以使用我的私有 k8s 代理,而无需添加任何带有 IP 地址的 ServiceEntry。

$ HTTPS_PROXY=squid.external:3128 curl https://something

当然,我无法在 istio-sider 中跟踪到该代理的出站流量。

于 2021-10-02T09:26:33.917 回答