Istio 虚拟服务和 Kubernetes 服务有什么区别?
What is the difference between Istio VirtualService and Kubernetes Service?
据我了解,Istio VirtualService
是一种抽象的东西,它试图向实际实现添加一个接口,例如 Kubernetes 中的服务或 Consul 中的类似东西。
当使用Kubernetes作为Istio的底层平台时,IstioVirtualService
和KubernetesService
有区别还是一样?
作为每个 Istio 的扩展,Istio 的 VirtualServices 提供了一些额外的功能,例如外部流量 routing/management(Pod 到外部通信、HTTPS 外部通信、路由、url 重写...)。
查看有关此文档的更多详细信息:https://istio.io/docs/reference/config/networking/virtual-service
它们都很有用,因为您需要 "classic" 服务来管理入口流量或服务到服务的通信。
史蒂夫
虚拟服务:
它定义了一组流量路由规则,以根据匹配条件应用于 kubernetes 服务或服务子集。这类似于 kubernetes Ingress 对象。它对Istio灵活强大的流量管理起到了关键作用。
Kubernetes 服务:
它可以是 pods 的逻辑集合,定义为 pods 之上的抽象,提供单一 DNS 名称或 IP。
Kubernetes 服务
Kubernetes service
管理 pod 的网络。它指定您的 pods 是在内部公开 (ClusterIP
)、在外部公开 (NodePort
或 LoadBalancer
) 还是作为其他 DNS 条目的 CNAME (externalName
)。
例如,此 foo-service
将公开带有标签 app: foo
的 pods。发送到端口 30007
上节点的任何请求都将转发到端口 80
.
上的 pod
apiVersion: v1
kind: Service
metadata:
name: foo-service
spec:
type: NodePort
selector:
app: foo
ports:
- port: 80
targetPort: 80
nodePort: 30007
Istio 虚拟服务
Istio virtualservice
比 Kuberenetes service
高一级。它可用于将流量路由、故障注入、重试和许多其他配置应用到 services
。
例如,对于 foo
.
的失败请求,此 foo-retry-virtualservice
将重试 3 次,每次超时 2 秒
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: foo-retry-virtualservice
spec:
hosts:
- foo
http:
- route:
- destination:
host: foo
retries:
attempts: 3
perTryTimeout: 2s
此 foo-delay-virtualservice
的另一个示例将对 foo
的 0.1% 的请求应用 0.5 秒的延迟。
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: foo-delay-virtualservice
spec:
hosts:
- foo
http:
- fault:
delay:
percentage:
value: 0.1
fixedDelay: 5s
route:
- destination:
host: foo
参考
https://kubernetes.io/docs/concepts/services-networking/service/
https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/
https://istio.io/latest/docs/reference/config/networking/virtual-service/
https://istio.io/latest/docs/concepts/traffic-management/#virtual-services
据我了解,Istio VirtualService
是一种抽象的东西,它试图向实际实现添加一个接口,例如 Kubernetes 中的服务或 Consul 中的类似东西。
当使用Kubernetes作为Istio的底层平台时,IstioVirtualService
和KubernetesService
有区别还是一样?
作为每个 Istio 的扩展,Istio 的 VirtualServices 提供了一些额外的功能,例如外部流量 routing/management(Pod 到外部通信、HTTPS 外部通信、路由、url 重写...)。
查看有关此文档的更多详细信息:https://istio.io/docs/reference/config/networking/virtual-service
它们都很有用,因为您需要 "classic" 服务来管理入口流量或服务到服务的通信。
史蒂夫
虚拟服务:
它定义了一组流量路由规则,以根据匹配条件应用于 kubernetes 服务或服务子集。这类似于 kubernetes Ingress 对象。它对Istio灵活强大的流量管理起到了关键作用。
Kubernetes 服务:
它可以是 pods 的逻辑集合,定义为 pods 之上的抽象,提供单一 DNS 名称或 IP。
Kubernetes 服务
Kubernetes service
管理 pod 的网络。它指定您的 pods 是在内部公开 (ClusterIP
)、在外部公开 (NodePort
或 LoadBalancer
) 还是作为其他 DNS 条目的 CNAME (externalName
)。
例如,此 foo-service
将公开带有标签 app: foo
的 pods。发送到端口 30007
上节点的任何请求都将转发到端口 80
.
apiVersion: v1
kind: Service
metadata:
name: foo-service
spec:
type: NodePort
selector:
app: foo
ports:
- port: 80
targetPort: 80
nodePort: 30007
Istio 虚拟服务
Istio virtualservice
比 Kuberenetes service
高一级。它可用于将流量路由、故障注入、重试和许多其他配置应用到 services
。
例如,对于 foo
.
foo-retry-virtualservice
将重试 3 次,每次超时 2 秒
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: foo-retry-virtualservice
spec:
hosts:
- foo
http:
- route:
- destination:
host: foo
retries:
attempts: 3
perTryTimeout: 2s
此 foo-delay-virtualservice
的另一个示例将对 foo
的 0.1% 的请求应用 0.5 秒的延迟。
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: foo-delay-virtualservice
spec:
hosts:
- foo
http:
- fault:
delay:
percentage:
value: 0.1
fixedDelay: 5s
route:
- destination:
host: foo
参考
https://kubernetes.io/docs/concepts/services-networking/service/ https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/ https://istio.io/latest/docs/reference/config/networking/virtual-service/ https://istio.io/latest/docs/concepts/traffic-management/#virtual-services