【问题标题】:Istio custom Gateway in a namespace命名空间中的 Istio 自定义网关
【发布时间】:2020-04-29 12:34:08
【问题描述】:

我正在尝试按照https://istio.io/blog/2019/custom-ingress-gateway 处的说明使用 Istio 网关和 VirtualService 公开服务

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: demo
  name: demo
  namespace: demo
spec:
  replicas: 1
  selector:
    matchLabels:
      app: demo
  template:
    metadata:
      labels:
        app: demo
    spec:
      containers:
      - image: nginx
        name: nginx
---
apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  labels:
    app: demo
  name: demo
  namespace: demo
spec:
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: demo
  type: ClusterIP
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: demo-gw
  namespace: demo
spec:
  selector:
    app: demo
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "example.com"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: demo-vs
  namespace: demo
spec:
  hosts:
  - "example.com"
  gateways:
  - demo-gw
  http:
  - route:
    - destination:
        host: demo

我正在使用minikube tunnel 运行minikube 集群,因此istio-ingressgateway 具有LoadBalancer IP。我已将/etc/hosts 修改为将example.com 指向istio-ingressgateway 服务IP,就像这样

10.111.251.46 example.com

请求似乎确实到达了 Envoy 代理。 curl -v -X TRACE http://example.com返回

*   Trying 10.111.251.46...
* TCP_NODELAY set
* Connected to example.com (10.111.251.46) port 80 (#0)
> TRACE / HTTP/1.1
> Host: example.com
> User-Agent: curl/7.64.1
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< date: Wed, 29 Apr 2020 12:32:49 GMT
< server: istio-envoy
< content-length: 0
< 
* Connection #0 to host example.com left intact
* Closing connection 0

【问题讨论】:

  • 您好,您链接的博文已过时。 This blog post was written assuming Istio 1, so some of this content may now be outdated.你的 minikube 集群上的 Istio 版本是什么?
  • 我在 Kubernetes 1.18、minikube 1.9.1 上运行 Istio 1.5

标签: kubernetes istio envoyproxy


【解决方案1】:

正如@Piotr Malec 在 cmets 中提到的那样

您链接的博文已过时。这篇博文是在假设 Istio 1 的情况下编写的,因此其中一些内容现在可能已经过时了。


我建议使用 istio operator,因为 istio 1.5 是添加自定义入口网关的最佳选择。

github issue 已经公开了,安装的方法很少。

例如,使用来自 comment 的 yaml,您可以使用默认入口网关安装 istio 默认配置文件,此外它还会在命名空间 dev 中创建第二个入口网关。


希望你觉得这很有用。

【讨论】:

    猜你喜欢
    • 2020-09-21
    • 1970-01-01
    • 2020-11-17
    • 1970-01-01
    • 2020-10-16
    • 1970-01-01
    • 1970-01-01
    • 2018-02-02
    相关资源
    最近更新 更多