Kubernetes Helm Redis Google Cloud MemoryStore - Service vs Endpoint

7/2/2019

I'm looking to configure Redis for Sidekiq and Rails in k8s. Using Google Cloud Memory Store with an IP address.

I have a helm template like the following (with gcpRedisMemorystore specified separately) - My question is what does the Service object add to the system? Is it necessary or does the Endpoint provide all the needed access?

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
-- stujo
google-cloud-memorystore
google-kubernetes-engine
kubernetes
kubernetes-helm

1 Answer

7/2/2019

Yes, you still need it.

Generally speaking, the Service is the name which is consumed by applications to connect to an Endpoint. Usually, a Service with a selector will automatically create a corresponding endpoint with the IP addresses of the Pods found by the selector.

When you define a Service without a selector you need to give the corresponding Endpoint of the same name so the Service has somewhere to go. This bit of information is in documentation but a bit buried. At https://kubernetes.io/docs/concepts/services-networking/service/#without-selectors it is mentioned in the second bullet point for headless services without selectors:

For headless services that do not define selectors, the endpoints controller does not create Endpoints records. However, the DNS system looks for and configures either:

  • CNAME records for ExternalName-type services.
  • A records for any Endpoints that share a name with the service, for all other types.
-- Andy Shinn
Source: StackOverflow