【问题标题】:Kubernetes Helm Redis Google Cloud MemoryStore - Service vs EndpointKubernetes Helm Redis Google Cloud MemoryStore - 服务与端点
【发布时间】:2019-07-02 16:41:20
【问题描述】:

我希望在 k8s 中为 Sidekiq 和 Rails 配置 Redis。使用带有 IP 地址的 Google Cloud Memory Store。

我有一个如下所示的 helm 模板(单独指定 gcpRedisMemorystore) - 我的问题是 Service 对象向系统添加了什么?是否有必要或 Endpoint 是否提供所有需要的访问权限?

charts/app/templates/app-memorystore.service.yaml

kind: Service
apiVersion: v1
metadata:
  name: app-memorystore
spec:
  type: ClusterIP
  clusterIP: None
  ports:
  - name: redis
    port: {{ .Values.gcpredis.port }}
    protocol: TCP
---
kind: Endpoints
apiVersion: v1
metadata:
  name: app-memorystore
subsets:
- addresses:
  - ip: {{ .Values.gcpredis.ip }}
  ports:
  - port: {{ .Values.gcpredis.port }}
    name: redis
    protocol: TCP

【问题讨论】:

    标签: kubernetes google-kubernetes-engine kubernetes-helm google-cloud-memorystore


    【解决方案1】:

    是的,你仍然需要它。

    一般来说,Service 是应用程序连接到 Endpoint 时使用的名称。通常,带有 selector 的 Service 会根据 selector 找到的 Pod 的 IP 地址自动创建一个对应的端点。

    当您在没有选择器的情况下定义服务时,您需要提供相应的同名端点,以便服务有去处。这一点信息在文档中,但有点隐藏。 https://kubernetes.io/docs/concepts/services-networking/service/#without-selectors 在第二个要点中提到了没有选择器的无头服务:

    对于没有定义选择器的无头服务,端点控制器不会创建端点记录。但是,DNS 系统会查找并配置:

    • ExternalName 类型服务的 CNAME 记录。
    • 所有其他类型的与服务共享名称的任何端点的记录。

    【讨论】:

    • 赞成但说When you define a "headless" Service like this you need to give the corresponding Endpoint of the same name so the Service has somewhere to go. 具有误导性。正如您的链接中提到的,无头服务也可以有选择器。你所说的适用于没有选择器的服务,无论它们是否是无头的。
    • 引用链接:Because this service has no selector, the corresponding Endpoint object will not be created automatically. You can manually map the service to the network address and port where it’s running, by adding an Endpoint object manually
    • 我修改了答案以澄清一点。
    • 谢谢!我难以理解的是选择器和无选择器的含义,以及选择器的使用方式。这个关于不同服务类型的文档有点帮助:kubernetes.io/docs/tutorials/kubernetes-basics/expose/…“没有选择器创建的服务也不会创建相应的端点对象”
    猜你喜欢
    • 2020-06-24
    • 1970-01-01
    • 1970-01-01
    • 2021-10-30
    • 1970-01-01
    • 2018-11-21
    • 2020-03-28
    • 2021-12-28
    • 1970-01-01
    相关资源
    最近更新 更多