Documentation
¶
Overview ¶
Package cluster manages the k3d cluster lifecycle for devrig.
Index ¶
- func BuildAndDeploy(ctx context.Context, name string, cfg *config.ClusterDeployConfig, ...) error
- func BuildImage(ctx context.Context, name string, cfg *config.ClusterImageConfig, ...) (string, error)
- func InstallAddons(ctx context.Context, addons map[string]config.AddonConfig, ...) error
- func KubectlApply(ctx context.Context, kubeconfig, path string) error
- func KubectlApplyDir(ctx context.Context, kubeconfig, path string, kustomize bool) error
- func KubectlPortForward(ctx context.Context, kubeconfig, namespace, target string, localPort uint16)
- func KubectlRollout(ctx context.Context, kubeconfig, namespace, name string) error
- func RegistryHostPort(containerName string) (uint16, error)
- func WaitForRegistry(ctx context.Context, port uint16) error
- func WatchAndRebuild(ctx context.Context, contextDir string, rebuild RebuildFunc) error
- func WriteLogCollectorManifest(otlpEndpoint string, logsCfg *config.ClusterLogsConfig, stateDir string) (string, error)
- type Manager
- func (m *Manager) ApplyRegistriesConfig(ctx context.Context, stateDir string) error
- func (m *Manager) ClusterName() string
- func (m *Manager) Delete(ctx context.Context) error
- func (m *Manager) Ensure(ctx context.Context) (*state.ClusterState, error)
- func (m *Manager) KubeconfigPath() string
- func (m *Manager) RegistryName() string
- type RebuildFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildAndDeploy ¶
func BuildAndDeploy( ctx context.Context, name string, cfg *config.ClusterDeployConfig, cs *state.ClusterState, stateDir string, ) error
BuildAndDeploy builds an image, pushes it to the registry, and applies the service manifests. It updates cs with the new image tag.
func BuildImage ¶
func BuildImage( ctx context.Context, name string, cfg *config.ClusterImageConfig, cs *state.ClusterState, ) (string, error)
BuildImage builds and pushes an image for a standalone image config (no deploy).
func InstallAddons ¶
func InstallAddons( ctx context.Context, addons map[string]config.AddonConfig, cs *state.ClusterState, stateDir string, ) error
InstallAddons installs all configured addons in topological order, then starts port-forwards. ctx cancellation stops the port-forwards.
func KubectlApply ¶
KubectlApply runs kubectl apply -f path with the given kubeconfig.
func KubectlApplyDir ¶
KubectlApplyDir runs kubectl apply -k for kustomize directories.
func KubectlPortForward ¶
func KubectlPortForward(ctx context.Context, kubeconfig, namespace, target string, localPort uint16)
KubectlPortForward starts a port-forward subprocess in the background. The caller is responsible for cancelling ctx to stop the forward.
func KubectlRollout ¶
KubectlRollout restarts a deployment by name in the given namespace.
func RegistryHostPort ¶
RegistryHostPort discovers the host-side port for the k3d registry container by inspecting its Docker port bindings.
func WaitForRegistry ¶
WaitForRegistry polls the registry's /v2/ endpoint until it responds 200.
func WatchAndRebuild ¶
func WatchAndRebuild(ctx context.Context, contextDir string, rebuild RebuildFunc) error
WatchAndRebuild watches contextDir for changes and calls rebuild when files change. It debounces by 500ms and cancels in-progress rebuilds on new changes. It blocks until ctx is cancelled.
func WriteLogCollectorManifest ¶
func WriteLogCollectorManifest( otlpEndpoint string, logsCfg *config.ClusterLogsConfig, stateDir string, ) (string, error)
WriteLogCollectorManifest writes a Fluent Bit DaemonSet manifest to stateDir/log-collector.yaml and returns the path.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager orchestrates the full cluster lifecycle.
func NewManager ¶
func NewManager(cfg *config.ClusterConfig, slug, stateDir, network string) *Manager
NewManager creates a cluster manager. slug and network are the devrig project slug and Docker network name.
func (*Manager) ApplyRegistriesConfig ¶
ApplyRegistriesConfig writes a registries.yaml to the k3d data dir if external registries are configured, for mirror/auth support.
func (*Manager) ClusterName ¶
ClusterName returns the k3d cluster name (dev-friendly if not configured).
func (*Manager) Ensure ¶
Ensure creates the cluster if it doesn't exist, then returns the cluster state (kubeconfig path, registry info).
func (*Manager) KubeconfigPath ¶
KubeconfigPath returns the path where the kubeconfig is written.
func (*Manager) RegistryName ¶
RegistryName returns the k3d registry container name.
type RebuildFunc ¶
RebuildFunc is called with the context when a file change is detected.