浏览器,那么它应该调用服务福在命名空间中
示例1 .
浏览器,那么它应该调用服务福在命名空间中
示例2 .
我正在使用 istio,问题是,如何配置网关,即绑定(bind)特定于命名空间:
看一个 istio 网关配置的例子:
$ kubectl apply -f - <<EOF
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: ns_example1
spec:
selector:
istio: ingressgateway # use Istio default gateway implementation
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "example1.example.com"
EOF
当我部署网关时,它将应用于当前命名空间,但我想指定一个命名空间。
如何将网关分配给特定的命名空间?
最佳答案
我认为这是 link应该回答你的问题。
有很多东西是你不需要的,但有一些想法你想应用到你的 istio 集群。
所以你需要 1 个网关和 2 个虚拟服务。
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: foocorp-gateway
namespace: default
spec:
selector:
istio: ingressgateway # use istio default ingress gateway
servers:
- port:
number: 80
name: http-example1
protocol: HTTP
hosts:
- "example1.example.com"
- port:
number: 80
name: http-example2
protocol: HTTP
hosts:
- "example2.example.com"
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: example1
namespace: ex1
spec:
hosts:
- "example1.example.com"
gateways:
- foocorp-gateway
http:
- match:
- uri:
exact: /
route:
- destination:
host: example1.ex1.svc.cluster.local
port:
number: 80
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: example2
namespace: ex2
spec:
hosts:
- "example2.example.com"
gateways:
- foocorp-gateway
http:
- match:
- uri:
exact: /
route:
- destination:
host: example2.ex2.svc.cluster.local
port:
number: 80
编辑
您可以在命名空间 ex1 和 ex2 中创建网关,然后只需更改虚拟服务中的网关字段,它应该可以工作。
记得添加命名空间/网关,不仅仅是网关名称,比如 there .
gateways:
- some-config-namespace/gateway-name
让我知道这是否对您有帮助。
关于kubernetes - 如何将网关绑定(bind)到特定的命名空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59576218/