Cloud Native 24 min read

SuperEdge Service Group Topology Awareness and Implementation Details

This article explains how SuperEdge extends native Kubernetes with a service‑group mechanism that provides topology‑aware service routing at the edge, compares it with the upstream Kubernetes service‑topology feature, and details the controller, wrapper, cache, and handler implementations with code examples.

Cloud Native Technology Community
Cloud Native Technology Community
Cloud Native Technology Community
SuperEdge Service Group Topology Awareness and Implementation Details

SuperEdge is an edge‑native container management system built on vanilla Kubernetes that brings cloud‑native capabilities to the edge, simplifying the deployment of applications from the cloud to edge nodes.

The platform introduces a service‑group feature that implements topology awareness using an application‑grid‑wrapper. Unlike the upstream Kubernetes service‑topology (available since v1.17 as an alpha feature), SuperEdge allows custom topology keys (gridUniqKey) and restricts each ServiceGrid to a single key, providing more flexible but stricter endpoint selection.

In Kubernetes, topology awareness is expressed via the topologyKeys field, which can contain "kubernetes.io/hostname", "topology.kubernetes.io/zone", and "topology.kubernetes.io/region". SuperEdge’s service‑group replaces these with a user‑defined key and annotates the generated Service with the corresponding topologyKeys annotation.

ServiceGrid Controller watches ServiceGrid CRDs, creates a single Service per ServiceGrid, and adds annotations that encode the custom topology key. The controller’s reconciliation loop follows three steps: create CRDs, enqueue ServiceGrid events, and process Service events to keep the Service in sync.

func (sgc *ServiceGridController) syncServiceGrid(key string) error { ... }

After the Service is created, the application‑grid‑wrapper runs as an HTTP server between kube‑proxy and the apiserver. It maintains a storageCache that stores nodes, services, and endpoints, and registers event handlers for each resource type.

type storageCache struct {
    hostName         string
    wrapperInCluster bool
    mu               sync.RWMutex
    servicesMap      map[types.NamespacedName]*serviceContainer
    endpointsMap     map[types.NamespacedName]*endpointsContainer
    nodesMap         map[types.NamespacedName]*nodeContainer
    serviceChan      chan<- watch.Event
    endpointsChan    chan<- watch.Event
}

The cache updates endpoints through pruneEndpoints, which filters endpoint addresses based on the topology keys of the associated Service and the labels of the host node and endpoint nodes. If a node’s labels change, the cache rebuilds the endpoint list to reflect the new topology.

func pruneEndpoints(hostName string, nodes map[types.NamespacedName]*nodeContainer, services map[types.NamespacedName]*serviceContainer, eps *v1.Endpoints, wrapperInCluster bool) *v1.Endpoints { ... }

Handlers for Node, Service, and Endpoint events update the cache and emit watch events when the topology‑filtered view changes. The wrapper’s HTTP handlers serve List and Watch requests for services and endpoints, returning the topology‑aware objects to kube‑proxy.

func (s *interceptorServer) interceptEndpointsRequest(handler http.Handler) http.Handler { ... }

In summary, SuperEdge’s service‑group mechanism provides a flexible, custom‑key topology awareness that ensures closed‑loop access within the same node unit, while the wrapper enables zero‑intrusion integration with existing Kubernetes networking components.

Future work suggests aligning SuperEdge’s algorithm with the upstream Kubernetes service‑topology feature and contributing the approach back to the community.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

CloudNativeKubernetesGoEdgeComputingServiceGroupSuperEdgeTopologyAwareness
Cloud Native Technology Community
Written by

Cloud Native Technology Community

The Cloud Native Technology Community, part of the CNBPA Cloud Native Technology Practice Alliance, focuses on evangelizing cutting‑edge cloud‑native technologies and practical implementations. It shares in‑depth content, case studies, and event/meetup information on containers, Kubernetes, DevOps, Service Mesh, and other cloud‑native tech, along with updates from the CNBPA alliance.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.