diff --git a/pkg/spegel/registry.go b/pkg/spegel/registry.go index 403b96f9fb..66fb0e06ec 100644 --- a/pkg/spegel/registry.go +++ b/pkg/spegel/registry.go @@ -30,8 +30,8 @@ func (c *Config) InjectMirror(nodeConfig *config.Node) error { registry.Mirrors = map[string]registries.Mirror{} } for host, mirror := range registry.Mirrors { - // Don't handle wildcard or local registry entries - if host != "*" && !docker.IsLocalhost(host) { + // Don't handle local registry entries + if !docker.IsLocalhost(host) { mirror.Endpoints = append([]string{mirrorURL}, mirror.Endpoints...) registry.Mirrors[host] = mirror } diff --git a/pkg/spegel/spegel.go b/pkg/spegel/spegel.go index a138d10eea..5a1b40cec3 100644 --- a/pkg/spegel/spegel.go +++ b/pkg/spegel/spegel.go @@ -12,6 +12,7 @@ import ( "strconv" "time" + "github.com/containerd/containerd/remotes/docker" "github.com/k3s-io/k3s/pkg/clientaccess" "github.com/k3s-io/k3s/pkg/daemons/config" "github.com/k3s-io/k3s/pkg/version" @@ -115,8 +116,8 @@ func (c *Config) Start(ctx context.Context, nodeConfig *config.Node) error { urls := []url.URL{} registries := []string{} for host := range nodeConfig.AgentConfig.Registry.Mirrors { - if u, err := url.Parse("https://" + host); err != nil || host == "*" { - logrus.Errorf("Distributed registry mirror skipping unsupported registry: %s", host) + if u, err := url.Parse("https://" + host); err != nil || docker.IsLocalhost(host) { + logrus.Errorf("Distributed registry mirror skipping invalid registry: %s", host) } else { urls = append(urls, *u) registries = append(registries, host)