diff --git a/pkg/client/registry.go b/pkg/client/registry.go index 06ca79241b..eef1ff7e15 100644 --- a/pkg/client/registry.go +++ b/pkg/client/registry.go @@ -191,6 +191,7 @@ func RegistryConnectNetworks(ctx context.Context, runtime runtimes.Runtime, regi // RegistryGenerateK3sConfig generates the k3s specific registries.yaml configuration for multiple registries func RegistryGenerateK3sConfig(ctx context.Context, registries []*k3d.Registry) (*k3s.Registry, error) { regConf := &k3s.Registry{} + rewritesConf := make(map[string]string) for _, reg := range registries { internalAddress := fmt.Sprintf("%s:%s", reg.Host, reg.ExposureOpts.Port.Port()) @@ -205,18 +206,21 @@ func RegistryGenerateK3sConfig(ctx context.Context, registries []*k3d.Registry) Endpoints: []string{ fmt.Sprintf("http://%s", internalAddress), }, + Rewrites: rewritesConf, } regConf.Mirrors[internalAddress] = k3s.Mirror{ Endpoints: []string{ fmt.Sprintf("http://%s", internalAddress), }, + Rewrites: rewritesConf, // stub out rewrites so we dont override with nil } if reg.Options.Proxy.RemoteURL != "" { regConf.Mirrors[reg.Options.Proxy.RemoteURL] = k3s.Mirror{ Endpoints: []string{fmt.Sprintf("http://%s", internalAddress)}, } + } } diff --git a/pkg/types/k3s/registry.go b/pkg/types/k3s/registry.go index a335fb8d49..b657182143 100644 --- a/pkg/types/k3s/registry.go +++ b/pkg/types/k3s/registry.go @@ -33,6 +33,10 @@ type Mirror struct { // with host specified. // The scheme, host and path from the endpoint URL will be used. Endpoints []string `toml:"endpoint" json:"endpoint"` + // Rewrites are rewrite rules for a registry. Rewrites change the tag of an + // image based on a regular expression. When using mirrors this can be helpful + // structure / organization of the mirror differs to the upstream. + Rewrites map[string]string `toml:"rewrite" json:"rewrite"` } // AuthConfig contains the config related to authentication to a specific registry