kubernetes-sigs / cluster-api

Home for Cluster API, a subproject of sig-cluster-lifecycle
https://cluster-api.sigs.k8s.io
Apache License 2.0
3.58k stars 1.31k forks source link

Annotate nodes with the cluster name #4044

Closed CecileRobertMichon closed 3 years ago

CecileRobertMichon commented 3 years ago

User Story

As a user, I would like to know which CAPI cluster a node is part of by doing a quick inspection of its metadata (eg. kubectl describe node).

As a user, I would like to know if a k8s cluster was built using Cluster API.

Detailed Description

Add a "cluster.x-k8s.io/cluster-name" annotation on every node part of the cluster. This can be done in the machine and machine pool controllers.

Anything else you would like to add:

[Miscellaneous information that will assist in solving the issue.]

/kind feature /assign

vincepri commented 3 years ago

/milestone v0.4.0

fmuyassarov commented 3 years ago

Hi @CecileRobertMichon , Are you planning to work on this feature? If not, can I work on this as a good first issue?

fabriziopandini commented 3 years ago

I'm wondering if the cluster name is enough to identify the Cluster API abstraction controlling this node. Is cluster-name enough or do we need namespace, and potentially a management Cluster-ID? Is it useful to track also the name of the machine managing this node? Is it useful to track higher-level abstraction managing the node (MachineDeployment, MachinePool, control plane object)?

CecileRobertMichon commented 3 years ago

@fmuyassarov I already have the change done locally, I open a PR today. I can help you find another good first issue though if you're interested.

@fabriziopandini the cluster name wouldn't give info about the machine controlling it, just the cluster it belongs to. I can add one for the machine / machine pool abstraction though, that should be pretty easy.

vincepri commented 3 years ago

Is cluster-name enough or do we need namespace, and potentially a management Cluster-ID?

We should probably add both namespace + name

@CecileRobertMichon Please take a look at this proposal as well https://github.com/kubernetes/enhancements/pull/2150 — It's a bit fuzzy on details and seems to be solving a different set of problems, but we should provide feedback there to align with the broader community.

I do like the idea that for now we can just annotate/label nodes instead of relying on future resources.

CecileRobertMichon commented 3 years ago

I'll add both namespace and name. But even that might not be enough as two different management clusters might have two target clusters with the same name in the same namespace.