kind icon indicating copy to clipboard operation
kind copied to clipboard

Allow adding container labels for kind nodes

Open hellt opened this issue 2 years ago • 12 comments

Hi @aojea @BenTheElder I would like to see if you consider the enhancement request to be able to provide container metadata via container labels a feasible request.

In containerlab (containerlab.dev) we would like to add support for spinning up kind clusters as part of a more extensive containerlab lab. In containerlab, the containers that are "orchestrated" by it, tagged accordingly so that additional tools around containerlab can filter containers and provide some automation around it.

When looking into kind API we didn't find a way to add metadata to kind containers (these are worker and master nodes). Is is possible to enhance API and allow providing tags to kind containers?

hellt avatar Jan 13 '23 13:01 hellt

If by container metadata via container labels you refer to the kindnode containers, they already have information necessary to identify them

            "Labels": {
                "io.x-k8s.kind.cluster": "kind",
                "io.x-k8s.kind.role": "control-plane"
            },

does it work for you?

aojea avatar Jan 13 '23 16:01 aojea

@aojea, the enhancement request is about being able to assign custom labels to the ones you do by default.

hellt avatar Jan 13 '23 17:01 hellt

I can see how that can be difficult to support with docker/podman duality Do you have time next week and we talk over this, this way I can use the opportunity to learn more about the project

aojea avatar Jan 13 '23 17:01 aojea

@aojea yes, we can sync up in twitter DMs to choose some time for a sync

hellt avatar Jan 14 '23 10:01 hellt

@aojea what came of this?

Previously we've rejected this feature. We're trying to keep the options to minimal essential ones as the project is tricky enough to maintain already and there's existing labels for identifying nodes from any particular kind cluster, as well as exported APIs and commands for listing nodes which can then be interacted with via docker/podman.

BenTheElder avatar Apr 18 '23 03:04 BenTheElder

I have a use case where we're creating multiple kind clusters in a CI container for testing. The CI container has the hosts docker.sock mounted in the container. Sometimes when something fails and the job exits you can end up having some dangling kind clusters remaining on the CI host. The job containers that are created by the runner have a bunch of labels on them identifying which repo, job, etc the container belongs to. I'd like to be able to put some of those same labels on the containers that kind creates so I can better identify dangling containers.

I'd be happy to contribute in my free time if this is a feature that you'd like to see added. Thanks!

logikone avatar Sep 08 '23 16:09 logikone

can you use a computed cluster name instead? (container names are computed from cluster name and are stable + predictable and labeled with the cluster name already)

BenTheElder avatar Sep 08 '23 16:09 BenTheElder

Ya, that's what I'm doing currently 👍

logikone avatar Sep 08 '23 17:09 logikone

this feature has been rejected, try my commit if you really want this, https://github.com/icefed/kind/tree/container-label

icefed avatar Jun 14 '24 09:06 icefed