配置 Istio Sidecar 以允许到外部主机的流量
Configure Istio Sidecar to allow trafic to external hosts
我有一个 sidecar,它只允许正在部署的命名空间上的出口流量。这也限制了外部呼叫。有没有办法将外部主机添加到 sidecar,例如:
apiVersion: "networking.istio.io/v1beta1",
kind: "Sidecar",
metadata:{
name: "egress-sidecar",
namespace: "namespace",
},
spec:{
workloadSelector:{
labels:{
app: 'target_app'
}
},
egress:[
{
hosts:[
"namespace/*",
"google.com/*" # <--- something like this, this does not work
]
}
],
outboundTrafficPolicy:{
mode: "REGISTRY_ONLY"
}
}
我认为您至少需要一个 ServiceEntry (https://istio.io/latest/docs/reference/config/networking/service-entry/) for the external service (e.g. www.google.com),然后您可以在 Sidecar 定义的出口部分引用它。根据您在哪个命名空间中注册提到的 ServicEntry,您可以在 Sidecar 定义的出口部分下的主机部分中定义以下内容:
*/www.google.com(服务网格中任意位置的 ServiceEntry)
./www.google.com(ServiceEntry 在与 Sidecar 定义相同的命名空间中)
(https://istio.io/latest/docs/reference/config/networking/sidecar/#IstioEgressListener)
我有一个 sidecar,它只允许正在部署的命名空间上的出口流量。这也限制了外部呼叫。有没有办法将外部主机添加到 sidecar,例如:
apiVersion: "networking.istio.io/v1beta1",
kind: "Sidecar",
metadata:{
name: "egress-sidecar",
namespace: "namespace",
},
spec:{
workloadSelector:{
labels:{
app: 'target_app'
}
},
egress:[
{
hosts:[
"namespace/*",
"google.com/*" # <--- something like this, this does not work
]
}
],
outboundTrafficPolicy:{
mode: "REGISTRY_ONLY"
}
}
我认为您至少需要一个 ServiceEntry (https://istio.io/latest/docs/reference/config/networking/service-entry/) for the external service (e.g. www.google.com),然后您可以在 Sidecar 定义的出口部分引用它。根据您在哪个命名空间中注册提到的 ServicEntry,您可以在 Sidecar 定义的出口部分下的主机部分中定义以下内容:
*/www.google.com(服务网格中任意位置的 ServiceEntry)
./www.google.com(ServiceEntry 在与 Sidecar 定义相同的命名空间中)
(https://istio.io/latest/docs/reference/config/networking/sidecar/#IstioEgressListener)