diff --git a/pkg/client/node.go b/pkg/client/node.go index bcf9e8a0..38c05910 100644 --- a/pkg/client/node.go +++ b/pkg/client/node.go @@ -305,6 +305,9 @@ func NodeCreate(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node, c for k, v := range k3d.DefaultObjectLabels { labels[k] = v } + for k, v := range k3d.DefaultObjectLabelsVar { + labels[k] = v + } for k, v := range node.Labels { labels[k] = v } diff --git a/pkg/client/registry.go b/pkg/client/registry.go index 1a0afbef..03b43155 100644 --- a/pkg/client/registry.go +++ b/pkg/client/registry.go @@ -88,6 +88,9 @@ func RegistryCreate(ctx context.Context, runtime runtimes.Runtime, reg *k3d.Regi for k, v := range k3d.DefaultObjectLabels { registryNode.Labels[k] = v } + for k, v := range k3d.DefaultObjectLabelsVar { + registryNode.Labels[k] = v + } // port registryNode.Ports = nat.PortMap{} diff --git a/pkg/runtimes/docker/volume.go b/pkg/runtimes/docker/volume.go index 59f8a9f0..7855ae43 100644 --- a/pkg/runtimes/docker/volume.go +++ b/pkg/runtimes/docker/volume.go @@ -52,6 +52,9 @@ func (d Docker) CreateVolume(ctx context.Context, name string, labels map[string for k, v := range k3d.DefaultObjectLabels { volumeCreateOptions.Labels[k] = v } + for k, v := range k3d.DefaultObjectLabelsVar { + volumeCreateOptions.Labels[k] = v + } vol, err := docker.VolumeCreate(ctx, volumeCreateOptions) if err != nil { diff --git a/pkg/tools/tools.go b/pkg/tools/tools.go index 7b64f716..34f03f13 100644 --- a/pkg/tools/tools.go +++ b/pkg/tools/tools.go @@ -201,6 +201,13 @@ func ImageImportIntoClusterMulti(ctx context.Context, runtime runtimes.Runtime, // startToolsNode will start a new k3d tools container and connect it to the network of the chosen cluster func startToolsNode(ctx context.Context, runtime runtimes.Runtime, cluster *k3d.Cluster, network string, volumes []string) (*k3d.Node, error) { + labels := map[string]string{} + for k, v := range k3d.DefaultObjectLabels { + labels[k] = v + } + for k, v := range k3d.DefaultObjectLabelsVar { + labels[k] = v + } node := &k3d.Node{ Name: fmt.Sprintf("%s-%s-tools", k3d.DefaultObjectNamePrefix, cluster.Name), Image: fmt.Sprintf("%s:%s", k3d.DefaultToolsImageRepo, version.GetHelperImageVersion()), diff --git a/pkg/types/types.go b/pkg/types/types.go index 1e0ca2c1..ba088985 100644 --- a/pkg/types/types.go +++ b/pkg/types/types.go @@ -106,8 +106,12 @@ var ClusterExternalNodeRoles = []Role{ // DefaultObjectLabels specifies a set of labels that will be attached to k3d objects by default var DefaultObjectLabels = map[string]string{ - "app": "k3d", - "k3d.version": version.Version, + "app": "k3d", +} + +// DefaultObjectLabelsVar specifies a set of labels that will be attached to k3d objects by default but are not static (e.g. across k3d versions) +var DefaultObjectLabelsVar = map[string]string{ + "k3d.version": version.GetVersion(), } // List of k3d technical label name