mesh

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: GPL-3.0, LGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package mesh manages the global infrastructure shared across all sind clusters.

Index

Constants

View Source
const (
	NetworkName      docker.NetworkName   = "sind-mesh"
	DNSContainerName docker.ContainerName = "sind-dns"
	SSHContainerName docker.ContainerName = "sind-ssh"
	SSHVolumeName    docker.VolumeName    = "sind-ssh-config"
)

Default-realm resource names. Production code uses Manager methods; these constants are used in tests as expected values for DefaultRealm.

View Source
const DNSImage = "coredns/coredns:latest"

DNSImage is the container image used for the mesh DNS server.

View Source
const DefaultRealm = "sind"

DefaultRealm is the realm name that produces the standard resource names.

View Source
const LabelRealm = "sind.realm"

LabelRealm is the Docker label applied to mesh resources (network, volumes) so realm-scoped listings can filter by label rather than by name prefix. pkg/cluster defines the same constant for cluster-scoped resources; keeping it local here avoids a pkg/mesh → pkg/cluster import.

View Source
const SSHImage = "ghcr.io/gsi-hpc/sind-node:latest"

SSHImage is the container image used for the SSH relay container. Uses the sind-node image which includes an ssh client and bash.

Variables

This section is empty.

Functions

This section is empty.

Types

type DNSRecord

type DNSRecord struct {
	Hostname string `json:"hostname"`
	IP       string `json:"ip"`
}

DNSRecord represents a single A record in the mesh DNS.

type Info added in v0.9.0

type Info struct {
	Network      string `json:"network"`
	DNSContainer string `json:"dns_container"`
	DNSIP        string `json:"dns_ip"`
	DNSZone      string `json:"dns_zone"`
	DNSImage     string `json:"dns_image"`
	SSHContainer string `json:"ssh_container"`
	SSHVolume    string `json:"ssh_volume"`
	SSHImage     string `json:"ssh_image"`
}

Info holds information about the mesh infrastructure for a realm.

type KnownHostEntry added in v0.9.0

type KnownHostEntry struct {
	Hostname string
	HostKey  string
}

KnownHostEntry holds a hostname and its SSH host key for batch registration.

type Manager

type Manager struct {
	Docker  *docker.Client
	Exec    cmdexec.Executor // executor for non-docker system commands (systemctl, resolvectl, etc.)
	Realm   string
	Pull    bool // force fresh image pull (--pull always)
	HostDNS bool // configure host DNS resolution via systemd-resolved
	// contains filtered or unexported fields
}

Manager handles global infrastructure resources shared across all clusters.

func NewManager

func NewManager(docker *docker.Client, realm string) *Manager

NewManager returns a Manager that operates on global resources through the given docker client. The realm determines resource naming: realm "sind" produces names like "sind-mesh", "sind-dns", etc.

func (*Manager) AddDNSRecord

func (m *Manager) AddDNSRecord(ctx context.Context, hostname, ip string) error

AddDNSRecord adds an A record to the mesh DNS Corefile and reloads CoreDNS. The hostname should be a fully qualified sind DNS name (e.g. "controller.dev.sind.sind").

func (*Manager) AddDNSRecords added in v0.9.0

func (m *Manager) AddDNSRecords(ctx context.Context, records []DNSRecord) error

AddDNSRecords adds multiple A records to the mesh DNS Corefile and reloads CoreDNS once. Existing entries for the same hostnames are replaced, making the operation idempotent on retry.

func (*Manager) AddKnownHost

func (m *Manager) AddKnownHost(ctx context.Context, hostname, hostKey string) error

AddKnownHost appends a host key entry to the known_hosts file in the SSH container. The hostKey should be the full key type and data (e.g. "ssh-ed25519 AAAA...").

func (*Manager) AddKnownHosts added in v0.9.0

func (m *Manager) AddKnownHosts(ctx context.Context, entries []KnownHostEntry) error

AddKnownHosts adds host key entries to the known_hosts file. Existing entries for the same hostnames are replaced, making the operation idempotent on retry.

func (*Manager) CleanupMesh

func (m *Manager) CleanupMesh(ctx context.Context) error

CleanupMesh removes all global infrastructure resources. This should only be called when the last cluster is deleted.

func (*Manager) ComposeProject

func (m *Manager) ComposeProject() string

ComposeProject returns the Docker Compose project name for this realm's mesh.

func (*Manager) Created added in v0.6.0

func (m *Manager) Created() bool

Created reports whether EnsureMesh created new mesh infrastructure in this invocation (i.e. the mesh did not already exist). This is used to decide whether cleanup should also tear down the mesh after a failed cluster create.

func (*Manager) DNSContainerName

func (m *Manager) DNSContainerName() docker.ContainerName

DNSContainerName returns the DNS container name for this realm.

func (*Manager) DNSPolkitAuthorized added in v0.5.0

func (m *Manager) DNSPolkitAuthorized(ctx context.Context) bool

DNSPolkitAuthorized checks if the current process can configure per-link DNS without interactive authentication.

func (*Manager) EnsureDNS

func (m *Manager) EnsureDNS(ctx context.Context) error

EnsureDNS creates the mesh DNS container if it does not already exist. The container runs CoreDNS on the mesh network, serving <realm>.sind records from inline hosts entries in the Corefile.

func (*Manager) EnsureMesh

func (m *Manager) EnsureMesh(ctx context.Context) error

EnsureMesh creates all global infrastructure resources (mesh network, DNS, SSH volume, SSH container) if they do not already exist.

func (*Manager) EnsureMeshNetwork

func (m *Manager) EnsureMeshNetwork(ctx context.Context) error

EnsureMeshNetwork creates the shared mesh network if it does not already exist.

func (*Manager) EnsureSSH

func (m *Manager) EnsureSSH(ctx context.Context) error

EnsureSSH creates the SSH relay container if it does not already exist. The container runs on the mesh network with the SSH volume mounted at /root/.ssh so that ssh automatically discovers the keypair and known_hosts.

func (*Manager) EnsureSSHVolume

func (m *Manager) EnsureSSHVolume(ctx context.Context) error

EnsureSSHVolume creates the SSH config volume and generates an ed25519 keypair if the volume does not already exist. The volume contains id_ed25519 (private key), id_ed25519.pub (public key), and an empty known_hosts file.

func (*Manager) GetDNSRecords

func (m *Manager) GetDNSRecords(ctx context.Context) ([]DNSRecord, error)

GetDNSRecords returns all A records currently served by the mesh DNS.

func (*Manager) GetInfo added in v0.9.0

func (m *Manager) GetInfo(ctx context.Context) (*Info, error)

GetInfo returns information about the mesh infrastructure for this realm. The mesh must exist (DNS container must be running to resolve the DNS IP). Returns an error containing "no mesh found for realm" if the DNS container does not exist yet.

func (*Manager) GetSSHKnownHosts added in v0.9.0

func (m *Manager) GetSSHKnownHosts(ctx context.Context) (string, error)

GetSSHKnownHosts reads the known_hosts file from the SSH container.

func (*Manager) GetSSHPrivateKey added in v0.9.0

func (m *Manager) GetSSHPrivateKey(ctx context.Context) (string, error)

GetSSHPrivateKey reads the SSH private key from the SSH container.

func (*Manager) GetSSHPublicKey added in v0.9.0

func (m *Manager) GetSSHPublicKey(ctx context.Context) (string, error)

GetSSHPublicKey reads the SSH public key from the SSH container.

func (*Manager) NetworkName

func (m *Manager) NetworkName() docker.NetworkName

NetworkName returns the mesh network name for this realm.

func (*Manager) RemoveDNSRecord

func (m *Manager) RemoveDNSRecord(ctx context.Context, hostname string) error

RemoveDNSRecord removes all A records for the given hostname from the mesh DNS Corefile and reloads CoreDNS.

func (*Manager) RemoveDNSRecords added in v0.9.0

func (m *Manager) RemoveDNSRecords(ctx context.Context, hostnames []string) error

RemoveDNSRecords removes all A records for the given hostnames from the mesh DNS Corefile and reloads CoreDNS once.

func (*Manager) RemoveKnownHost

func (m *Manager) RemoveKnownHost(ctx context.Context, hostname string) error

RemoveKnownHost removes all entries for the given hostname from the known_hosts file in the SSH container.

func (*Manager) RemoveKnownHosts added in v0.9.0

func (m *Manager) RemoveKnownHosts(ctx context.Context, hostnames []string) error

RemoveKnownHosts removes all entries for the given hostnames from the known_hosts file in a single operation.

func (*Manager) ResolvedActive added in v0.5.0

func (m *Manager) ResolvedActive(ctx context.Context) bool

ResolvedActive checks if systemd-resolved is running.

func (*Manager) SSHContainerName

func (m *Manager) SSHContainerName() docker.ContainerName

SSHContainerName returns the SSH container name for this realm.

func (*Manager) SSHKeygenName

func (m *Manager) SSHKeygenName() docker.ContainerName

SSHKeygenName returns the temporary keygen container name for this realm.

func (*Manager) SSHVolumeName

func (m *Manager) SSHVolumeName() docker.VolumeName

SSHVolumeName returns the SSH volume name for this realm.

Jump to

Keyboard shortcuts

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