Documentation
¶
Overview ¶
Package geo locates clusters on Earth from node region/zone labels.
Kubernetes nodes carry well-known topology labels populated by every major cloud provider's controller-manager: topology.kubernetes.io/region and topology.kubernetes.io/zone. Older clusters used failure-domain.beta.* on the same data. By reading these on every node and consulting an embedded region-to-coordinate table, we can place a cluster on a globe with no manual configuration.
Package geo locates clusters on Earth from their node region/zone labels. Coordinates here are the approximate centroid of each cloud provider's public region. They are intentionally approximate — exact data-center coordinates are not always published, and what matters for a fleet globe is "this cluster is in Frankfurt, not Tokyo", not GPS-level accuracy.
Index ¶
Constants ¶
const Name = "geo"
Name is the registry key for this scanner.
Variables ¶
This section is empty.
Functions ¶
func NewScanner ¶
NewScanner returns a scanner that reads node region/zone labels and resolves a single representative coordinate for the cluster.
Resolution order, highest priority first:
- ConfigMap kube-system/fleetsweeper with lat/lng/site keys.
- Annotations on the kube-system namespace (fleetsweeper.io/lat etc.).
- Auto-detect from node region labels.
Whichever source wins is recorded in Data.Source so consumers can show the operator which configuration is currently active.
Types ¶
type Coord ¶
type Coord struct {
// Lat is degrees north (positive) or south (negative).
Lat float64
// Lng is degrees east (positive) or west (negative).
Lng float64
// Provider is the cloud provider this region belongs to.
Provider string
// City is a human-readable label for the region centroid.
City string
}
Coord is the approximate centroid (latitude, longitude) of a region.
func Lookup ¶
Lookup returns the coordinate for a region name, or ok=false when the region is not in the table. Callers should fall back to zone parsing (a zone like "us-east-1a" trims to a known region).
func LookupZone ¶
LookupZone strips a trailing single-letter zone suffix and looks up the resulting region. AWS zones look like "us-east-1a"; GCP zones look like "us-central1-b". Both shapes are handled.
type Data ¶
type Data struct {
// Region is the inferred cloud region (for example "us-east-1").
Region string `json:"region,omitempty"`
// Provider is the inferred provider name (AWS, GCP, Azure, ...).
Provider string `json:"provider,omitempty"`
// City is a human-readable name for the region centroid.
City string `json:"city,omitempty"`
// Site is the operator-supplied site label (when an in-cluster
// annotation or ConfigMap is present).
Site string `json:"site,omitempty"`
// Notes is operator-supplied free-form text.
Notes string `json:"notes,omitempty"`
// Lat is latitude in degrees. NaN when unknown; serialized as 0.
Lat float64 `json:"lat"`
// Lng is longitude in degrees. NaN when unknown; serialized as 0.
Lng float64 `json:"lng"`
// HasLocation is true when Lat/Lng were resolved.
HasLocation bool `json:"has_location"`
// Source describes where the location came from: "configmap",
// "annotation", "auto", or "" when unresolved. The handler that merges
// manual DB overrides treats "configmap" and "annotation" as
// operator-asserted and surfaces them as "manual" on the globe.
Source string `json:"source,omitempty"`
// Regions lists every distinct region observed across nodes (a single
// cluster usually has one, but federated clusters can span multiple).
Regions []string `json:"regions,omitempty"`
// Zones lists every distinct zone observed across nodes.
Zones []string `json:"zones,omitempty"`
// NodeCount is the number of nodes inspected.
NodeCount int `json:"node_count"`
// LocatedNodes is the number of nodes whose region was resolved.
LocatedNodes int `json:"located_nodes"`
}
Data is the geographic placement information for one cluster.