Documentation
¶
Overview ¶
Package agent implements the faros agent that connects edges to the hub.
Index ¶
- func AgentConfigPath(edgeName string) (string, error)
- func AgentKubeconfigPath(edgeName string) (string, error)
- func AgentKubeconfigSecretName(edgeName string) string
- func DeleteAgentKubeconfig(edgeName string) error
- func IsInCluster() bool
- func LoadAgentKubeconfig(edgeName string) (string, error)
- func LoadKubeconfigFromSecret(edgeName string) (string, error)
- func SaveAgentConfig(edgeName, hubURL, token string) error
- func SaveAgentKubeconfig(edgeName, kubeconfigB64 string) error
- func SaveKubeconfigToSecret(edgeName, kubeconfigData string) error
- func ValidateAgentKubeconfig(kubeconfigPath string, insecureSkipTLS bool) error
- type Agent
- type AgentConfig
- type AgentType
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AgentConfigPath ¶
AgentConfigPath returns the path for the per-edge agent config file. Default location: ~/.faros/agent-<edgeName>.json
func AgentKubeconfigPath ¶
AgentKubeconfigPath returns the path for the per-edge agent kubeconfig file. Default location: ~/.faros/agent-<edgeName>.kubeconfig
func AgentKubeconfigSecretName ¶
AgentKubeconfigSecretName returns the name of the Secret used to persist the hub kubeconfig for the given edge when running in-cluster.
func DeleteAgentKubeconfig ¶
DeleteAgentKubeconfig removes a previously saved agent kubeconfig from disk.
func IsInCluster ¶
func IsInCluster() bool
IsInCluster returns true when the process is running inside a Kubernetes Pod.
func LoadAgentKubeconfig ¶
LoadAgentKubeconfig reads a previously saved agent kubeconfig from disk. Returns an empty string without error if the file does not exist yet.
func LoadKubeconfigFromSecret ¶
LoadKubeconfigFromSecret reads the hub kubeconfig from the in-cluster Secret. Returns ("", nil) when the Secret does not exist yet (first boot before token exchange).
func SaveAgentConfig ¶
SaveAgentConfig persists the durable agent token to disk so the agent can reconnect without the bootstrap join token after the first successful auth.
func SaveAgentKubeconfig ¶
SaveAgentKubeconfig decodes the base64-encoded kubeconfig returned by the hub (via X-Faros-Agent-Kubeconfig header) and persists it to disk so the agent can reconnect without the bootstrap join token after the first successful auth.
func SaveKubeconfigToSecret ¶
SaveKubeconfigToSecret writes the hub kubeconfig to the in-cluster Secret so that it survives a pod restart.
func ValidateAgentKubeconfig ¶
ValidateAgentKubeconfig checks whether the saved kubeconfig still has valid credentials by attempting a lightweight API call. Returns an error only if authentication definitively fails (401 Unauthorized — token revoked, e.g. after Edge recreation). All other errors (403 Forbidden, timeouts, network errors) return nil because they don't prove the token is invalid — the hub may be temporarily unreachable or the RBAC may not permit the probe call. When insecureSkipTLS is true, TLS certificate verification is disabled.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent is the faros agent that connects an edge to the hub.
type AgentConfig ¶
AgentConfig holds the locally persisted agent configuration. It is written to disk after the first successful join-token authentication so that the agent can reconnect on restart without needing the bootstrap join token again.
func LoadAgentConfig ¶
func LoadAgentConfig(edgeName string) (*AgentConfig, error)
LoadAgentConfig reads a previously saved agent config from disk. Returns nil without error if the config file does not exist yet.
type AgentType ¶
type AgentType string
AgentType discriminates whether the agent connects a Kubernetes cluster or a bare-metal / systemd server to the hub.
const ( // AgentTypeKubernetes connects a Kubernetes cluster (registers an Edge with spec.type=kubernetes). AgentTypeKubernetes AgentType = "kubernetes" // AgentTypeServer connects a bare-metal / systemd host via SSH // (registers an Edge with spec.type=server). AgentTypeServer AgentType = "server" )
type Options ¶
type Options struct {
HubURL string
HubKubeconfig string
HubContext string
TunnelURL string // Separate URL for reverse tunnel (defaults to hubConfig.Host)
Token string
EdgeName string
Kubeconfig string
Context string
Labels map[string]string
// Type controls whether the agent registers as a Kubernetes edge or a
// Server edge. Defaults to AgentTypeKubernetes.
Type AgentType
// InsecureSkipTLSVerify disables TLS certificate verification for the hub
// connection. Should only be used in development/testing; never in production.
InsecureSkipTLSVerify bool
// SSHProxyPort is the local port of the SSH daemon the agent proxies to.
// Defaults to 22; override in tests to avoid conflicts with the host sshd.
SSHProxyPort int
// SSHUser is the SSH username to authenticate as on server-type edges.
// Defaults to the current user if not set.
SSHUser string
// SSHPassword is the SSH password for password-based authentication.
// Prefer SSHPrivateKeyPath for better security.
SSHPassword string
// SSHPrivateKeyPath is the path to an SSH private key file for key-based auth.
SSHPrivateKeyPath string
// Cluster is the kcp logical cluster path (e.g., "root:faros:user-default").
// If not set, it's extracted from the SA token (for kubeconfig-based auth)
// or defaults to "default" (for static token auth).
Cluster string
// UsingSavedKubeconfig is set to true when the agent loaded a saved
// kubeconfig from a previous join-token registration. When true, edge
// registration is skipped (the edge was already registered).
UsingSavedKubeconfig bool
// DebugAddr, if non-empty, is the bind address for the agent's debug
// HTTP server. It exposes /healthz and the standard /debug/pprof/*
// endpoints. Use "127.0.0.1:6060" for local-only access; bind to a
// non-loopback address only when port-forwarding is not an option.
DebugAddr string
}
Options holds configuration for the agent.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package discovery detects HTTP services running on the edge host next to the agent (e.g.
|
Package discovery detects HTTP services running on the edge host next to the agent (e.g. |
|
Package reconciler reconciles workloads on the agent side: it watches the edge's Placements in the tenant workspace and materializes each as a local Deployment.
|
Package reconciler reconciles workloads on the agent side: it watches the edge's Placements in the tenant workspace and materializes each as a local Deployment. |
|
Package status reports agent status back to the hub.
|
Package status reports agent status back to the hub. |
|
Package tunnel implements reverse-dial tunneling between agent and hub.
|
Package tunnel implements reverse-dial tunneling between agent and hub. |