server

package
v0.0.0-...-c46dd35 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2026 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Overview

Package server implements a gRPC server for the CNI plugin interface. It handles pod registration and deregistration, queries node metadata, stores pod data locally, and registers endpoints in the service registry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CNIServer

type CNIServer struct {
	cniv1.UnimplementedCNIServiceServer
	xds.Server
	// contains filtered or unexported fields
}

CNIServer is a gRPC server that implements the CNI plugin interface. It handles pod registration and deregistration requests, stores pod data locally, and registers service endpoints in the registry. The server also queries Kubernetes node metadata (region and zone) for topology-aware routing.

CNIServer embeds xds.Server and implements the ServerCallback interface to query node metadata before accepting client connections.

func NewCNIServer

func NewCNIServer(clusterName string, nodeName string, trustDomain string, localStorage storage.Storage[*cniv1.CNIPod], registry registry.Registry, snapshotCache *cache.SnapshotCache, ackTracker *ack.Tracker, spireBridge *spire.Bridge, log *slog.Logger, k8sClient client.Client, informers ctrlcache.Informers, cfg *CNIServerConfig) (*CNIServer, error)

NewCNIServer creates a new CNI gRPC server. The server listens on a Unix domain socket and registers the CNI service with protovalidate middleware for request validation.

func (*CNIServer) AddPod

AddPod handles CNI ADD requests for a pod. It enriches the pod data with Kubernetes annotations and labels, validates that the pod should be managed (not in system namespaces or lacking the aether service label), stores the pod locally, and registers its endpoints in the service registry.

func (*CNIServer) PreListen

func (s *CNIServer) PreListen(ctx context.Context) error

PreListen queries Kubernetes node metadata before the server starts accepting connections. It retrieves the region and zone labels from the node object.

func (*CNIServer) RemovePod

RemovePod handles CNI DEL requests for a pod. It retrieves the pod from local storage, validates that it should be managed, unregisters its endpoints from the service registry, and removes the pod from local storage. If the pod is not found locally, it assumes the pod was either already removed or ignored.

type CNIServerConfig

type CNIServerConfig struct {
	// SocketPath is the Unix domain socket path where the CNI gRPC server listens.
	SocketPath string
	// ProxyHealthSocketPath is the Unix domain socket of the proxy's health
	// gateway listener, probed by the liveness loop for per-pod app health.
	// It must match the path the snapshot cache programs into the gateway
	// listener (the shared default); it is configurable for tests.
	ProxyHealthSocketPath string
}

CNIServerConfig holds configuration for the CNIServer.

func NewCNIServerConfig

func NewCNIServerConfig() *CNIServerConfig

NewCNIServerConfig creates a new CNIServerConfig with default values. The default socket path is the standard CNI socket path.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL