Documentation
¶
Overview ¶
Package registrystage provides registry setup and connection stages for cluster creation. It handles mirror registry provisioning, network creation, and containerd configuration for Kind, K3d, and Talos distributions.
Index ¶
- Constants
- Variables
- func ConnectRegistriesToClusterNetwork(params StageParams) error
- func EnsureDockerNetworkExists(ctx context.Context, dockerClient client.APIClient, networkName string, ...) error
- func GetKindMirrorsDir(clusterCfg *v1alpha1.Cluster) string
- func K3dConnectAction(_ *Context) func(context.Context, client.APIClient) error
- func K3dMirrorAction(ctx *Context) func(context.Context, client.APIClient) error
- func KindConnectAction(ctx *Context) func(context.Context, client.APIClient) error
- func KindMirrorAction(ctx *Context) func(context.Context, client.APIClient) error
- func PrepareK3dConfigWithMirrors(clusterCfg *v1alpha1.Cluster, k3dConfig *v1alpha5.SimpleConfig, ...) bool
- func PrepareKindConfigWithMirrors(clusterCfg *v1alpha1.Cluster, cfgManager *ksailconfigmanager.ConfigManager, ...) bool
- func PrepareTalosConfigWithMirrors(clusterCfg *v1alpha1.Cluster, talosConfig *talosconfigmanager.Configs, ...) bool
- func ResolveTalosClusterName(talosConfig *talosconfigmanager.Configs) string
- func ResolveTalosNetworkCIDR(_ *talosconfigmanager.Configs) string
- func RunStage(cmd *cobra.Command, clusterCfg *v1alpha1.Cluster, deps lifecycle.Deps, ...) error
- func SetupMirrorRegistries(params StageParams) error
- func SetupTalosMirrorRegistries(ctx context.Context, dockerAPIClient client.APIClient, clusterName string, ...) error
- func TalosConnectAction(_ *Context) func(context.Context, client.APIClient) error
- func TalosMirrorAction(ctx *Context) func(context.Context, client.APIClient) error
- type Context
- type Definition
- type DockerClientInvoker
- type Handler
- type Info
- type K3dRegistryAction
- type Role
- type StageParams
Constants ¶
const ( MirrorStageTitle = "Create mirror registry..." MirrorStageEmoji = "🪞" MirrorStageActivity = "creating mirror registries" MirrorStageSuccess = "mirror registries created" MirrorStageFailure = "failed to setup registries" ConnectStageTitle = "Connect registry..." ConnectStageEmoji = "🔗" ConnectStageActivity = "connecting registries" ConnectStageSuccess = "registries connected" ConnectStageFailure = "failed to connect registries" )
Stage message constants for registry operations.
const DefaultNetworkMTU = "1500"
DefaultNetworkMTU is the default MTU for Docker bridge networks. Required by the Talos SDK's Reflect() function which reads com.docker.network.driver.mtu to parse network state.
Variables ¶
var ConnectInfo = Info{ Title: ConnectStageTitle, Emoji: ConnectStageEmoji, Activity: ConnectStageActivity, Success: ConnectStageSuccess, FailurePrefix: ConnectStageFailure, }
ConnectInfo returns the stage info for registry connection.
var MirrorInfo = Info{ Title: MirrorStageTitle, Emoji: MirrorStageEmoji, Activity: MirrorStageActivity, Success: MirrorStageSuccess, FailurePrefix: MirrorStageFailure, }
MirrorInfo returns the stage info for mirror registry creation.
var StageDefinitions = map[Role]Definition{ RoleMirror: { Info: MirrorInfo, KindAction: KindMirrorAction, K3dAction: K3dMirrorAction, TalosAction: TalosMirrorAction, }, RoleConnect: { Info: ConnectInfo, KindAction: KindConnectAction, K3dAction: K3dConnectAction, TalosAction: TalosConnectAction, }, }
StageDefinitions maps stage roles to their definitions.
Functions ¶
func ConnectRegistriesToClusterNetwork ¶
func ConnectRegistriesToClusterNetwork(params StageParams) error
ConnectRegistriesToClusterNetwork attaches mirror registries to the cluster network after creation.
func EnsureDockerNetworkExists ¶
func EnsureDockerNetworkExists( ctx context.Context, dockerClient client.APIClient, networkName string, networkCIDR string, writer io.Writer, ) error
EnsureDockerNetworkExists creates a Docker network if it doesn't already exist. This is used to pre-create the cluster network before registry setup, allowing registry containers to be connected and accessible via Docker DNS when nodes start pulling images during boot.
The network is created with Talos-compatible labels and CIDR so that the Talos SDK will recognize and reuse it when creating the cluster.
func GetKindMirrorsDir ¶
GetKindMirrorsDir returns the configured Kind mirrors directory or the default.
func K3dConnectAction ¶
K3dConnectAction returns the action function for K3d registry connection.
func K3dMirrorAction ¶
K3dMirrorAction returns the action function for K3d mirror registry setup.
func KindConnectAction ¶
KindConnectAction returns the action function for Kind registry connection.
func KindMirrorAction ¶
KindMirrorAction returns the action function for Kind mirror registry setup.
func PrepareK3dConfigWithMirrors ¶
func PrepareK3dConfigWithMirrors( clusterCfg *v1alpha1.Cluster, k3dConfig *v1alpha5.SimpleConfig, mirrorSpecs []registry.MirrorSpec, ) bool
PrepareK3dConfigWithMirrors prepares the K3d config by setting up mirror registries. Returns true if mirror configuration is needed, false otherwise.
func PrepareKindConfigWithMirrors ¶
func PrepareKindConfigWithMirrors( clusterCfg *v1alpha1.Cluster, cfgManager *ksailconfigmanager.ConfigManager, kindConfig *v1alpha4.Cluster, ) bool
PrepareKindConfigWithMirrors prepares the Kind config by setting up hosts directory for mirrors. Returns true if mirror configuration is needed, false otherwise. This uses the modern hosts directory pattern instead of deprecated ContainerdConfigPatches.
func PrepareTalosConfigWithMirrors ¶
func PrepareTalosConfigWithMirrors( clusterCfg *v1alpha1.Cluster, talosConfig *talosconfigmanager.Configs, mirrorSpecs []registry.MirrorSpec, ) bool
PrepareTalosConfigWithMirrors prepares the Talos config by setting up mirror registries. Returns true if mirror configuration is needed, false otherwise.
func ResolveTalosClusterName ¶
func ResolveTalosClusterName(talosConfig *talosconfigmanager.Configs) string
ResolveTalosClusterName extracts the cluster name from Talos config or returns the default.
func ResolveTalosNetworkCIDR ¶
func ResolveTalosNetworkCIDR(_ *talosconfigmanager.Configs) string
ResolveTalosNetworkCIDR returns the Docker network CIDR for Talos. This is always DefaultNetworkCIDR (10.5.0.0/24) - NOT the pod CIDR from cluster config. The Talos SDK uses this CIDR for the Docker bridge network that nodes connect to.
func RunStage ¶
func RunStage( cmd *cobra.Command, clusterCfg *v1alpha1.Cluster, deps lifecycle.Deps, cfgManager *ksailconfigmanager.ConfigManager, kindConfig *v1alpha4.Cluster, k3dConfig *v1alpha5.SimpleConfig, talosConfig *talosconfigmanager.Configs, role Role, firstActivityShown *bool, dockerInvoker DockerClientInvoker, ) error
RunStage executes the registry stage for the given role.
func SetupMirrorRegistries ¶
func SetupMirrorRegistries(params StageParams) error
SetupMirrorRegistries configures mirror registries before cluster creation.
func SetupTalosMirrorRegistries ¶
func SetupTalosMirrorRegistries( ctx context.Context, dockerAPIClient client.APIClient, clusterName string, networkName string, networkCIDR string, registryInfos []registry.Info, writer io.Writer, ) error
SetupTalosMirrorRegistries creates network, registry containers, and connects them.
func TalosConnectAction ¶
TalosConnectAction returns the action function for Talos registry connection.
Types ¶
type Context ¶
type Context struct {
Cmd *cobra.Command
ClusterCfg *v1alpha1.Cluster
KindConfig *v1alpha4.Cluster
K3dConfig *v1alpha5.SimpleConfig
TalosConfig *talosconfigmanager.Configs
MirrorSpecs []registry.MirrorSpec
}
Context contains all the configuration needed for registry stage execution.
type Definition ¶
type Definition struct {
Info Info
KindAction func(*Context) func(context.Context, client.APIClient) error
K3dAction func(*Context) func(context.Context, client.APIClient) error
TalosAction func(*Context) func(context.Context, client.APIClient) error
}
Definition maps a stage role to its info and distribution-specific actions.
type DockerClientInvoker ¶
DockerClientInvoker is a function that invokes Docker client operations. Can be overridden in tests to avoid real Docker connections.
var DefaultDockerClientInvoker DockerClientInvoker = docker.WithClient
DefaultDockerClientInvoker is the default Docker client invoker.
type K3dRegistryAction ¶
type K3dRegistryAction func( context.Context, *v1alpha5.SimpleConfig, string, client.APIClient, io.Writer, ) error
K3dRegistryAction is the function signature for K3d registry actions.
type StageParams ¶
type StageParams struct {
Cmd *cobra.Command
ClusterCfg *v1alpha1.Cluster
Deps lifecycle.Deps
CfgManager *ksailconfigmanager.ConfigManager
KindConfig *v1alpha4.Cluster
K3dConfig *v1alpha5.SimpleConfig
TalosConfig *talosconfigmanager.Configs
FirstActivityShown *bool
DockerInvoker DockerClientInvoker
}
StageParams bundles all parameters needed for registry stage execution. This reduces code duplication between SetupMirrorRegistries and ConnectRegistriesToClusterNetwork.