Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service 与 Endpoints、EndpointSlice 那些事 | 袁昊的学习笔记 #67

Open
howieyuen opened this issue Jan 23, 2024 · 0 comments
Open

Comments

@howieyuen
Copy link
Owner

https://howieyuen.github.io/docs/kubernetes/sig-network/svc-ep-epslice/

Service 与 Endpoints、EndpointSlice 那些事 # Service 资源 # k8s Service 定义了这样一种抽象:逻辑上的一组 Pod,一种可以访问它们的策略 —— 通常称为微服务。 Service 所针对的 Pod 集合通常是通过 LabelSelector 来确定的。 LabelSelector 选中的 Pod,将会自动创建与 Service 同名且同 Namespace 的 Endpoint 对象,将 Pod 的 IP 写入其中。
如果没有 LabelSelector,用户可能是希望 Service 关联的后端是集群外的服务,或者是其他 Namespace; 如果用户还想要使用负载均衡服务,需要自行创建与 Service 同名的 Endpoints 对象。
Service 类型 # k8s Service 分为 4 种类型(svc.spec.type):
ClusterIP:通过集群的内部 IP 暴露服务,选择该值时服务只能够在集群内部访问。 这也是默认的 ServiceType。 NodePort:通过每个节点上的 IP 和静态端口(NodePort)暴露服务。 NodePort 服务会路由到自动创建的 ClusterIP 服务。 通过请求 :,你可以从集群的外部访问一个 NodePort 服务。 LoadBalance:使用云提供商的负载均衡器向外部暴露服务。 外部负载均衡器可以将流量路由到自动创建的 NodePort 服务和 ClusterIP 服务上。 ExternalName:通过返回 CNAME 和对应值,可以将服务映射到 externalName 字段的内容; 例如,foo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant