From 0ee299dc7df706c81af2670d755bf9d6de9ff303 Mon Sep 17 00:00:00 2001 From: Mike Beaumont Date: Tue, 26 Mar 2024 17:00:17 +0100 Subject: [PATCH] docs: add headless Service Signed-off-by: Mike Beaumont --- .../041-meshservice-kubernetes-ux.md | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/docs/madr/decisions/041-meshservice-kubernetes-ux.md b/docs/madr/decisions/041-meshservice-kubernetes-ux.md index e0f48bf96110..2bc60dd7efa5 100644 --- a/docs/madr/decisions/041-meshservice-kubernetes-ux.md +++ b/docs/madr/decisions/041-meshservice-kubernetes-ux.md @@ -47,6 +47,35 @@ including supporting named `targetPorts`. Note that we only support `Service.ports[].protocol: TCP`, which is also the default. +### Headless Service with selectors + +In Kubernetes, a headless Service with selectors is used to create a DNS record +for every Pod selected by the Service that points directly to the Pod's IP. + +To support this with Kuma, we will create a `MeshService` per Pod, each +represented by the hostname allocated by the headless Service and the Pod +IP as the "VIP" and single endpoint. + +In order to do this we need to have a list of all the Pods selected by the +Service, which we can get by looking at `EndpointSlices`. These resources hold a +list of endpoints, each of which has a `targetRef`. If the `targetRef` is `kind: +Pod`, we can rely on the naming of `Dataplane` objects and directly select a +given `Dataplane` by setting `spec.selector.dataplaneName` to the name of the +`Pod`. + +``` +kind: MeshService +spec: + selector: + dataplaneName: pod-1 + # dataplaneTags: ... +``` + +#### Policy matching + +Note that this prevents using `kind: MeshService` to select all Pods of a +StatefulSet. In another MADR, we will cover this use case. + ### Positive Consequences * Users don't have to think about creating `MeshService`