Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClusterClass: controlplane MHC setting bad selector labels #11549

Open
swarren83 opened this issue Dec 9, 2024 · 6 comments
Open

ClusterClass: controlplane MHC setting bad selector labels #11549

swarren83 opened this issue Dec 9, 2024 · 6 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-priority Indicates an issue lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@swarren83
Copy link

What steps did you take and what happened?

Specifying a machineHealthCheck in spec.controlPlane sets the following selector labels up on the MHC resource:

  selector:
    matchLabels:
      cluster.x-k8s.io/control-plane: ''
      topology.cluster.x-k8s.io/owned: ''

While the control plane machines are getting the following labels set:

  labels:
    cluster.x-k8s.io/cluster-name: my-awesome-cluster
    cluster.x-k8s.io/control-plane: ''

Example mhc configuration

spec:
  controlPlane:
    machineHealthCheck:
      maxUnhealthy: 33%
      nodeStartupTimeout: 10m0s
      unhealthyConditions:
        - status: Unknown
          timeout: 5m0s
          type: Ready
        - status: 'False'
          timeout: 5m0s
          type: Ready

What did you expect to happen?

The MHC resource spec.selector.matchLabels should be such that they match labels applied to the control plane Machine.

Cluster API version

v1.8.4

Kubernetes version

v1.27.14

Anything else you would like to add?

CAPI is running on a Rancher cluster, v2.7.9

Label(s) to be applied

/kind bug
One or more /area label. See https://github.com/kubernetes-sigs/cluster-api/labels?q=area for the list of labels.

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. needs-priority Indicates an issue lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Dec 9, 2024
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If CAPI contributors determine this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@sbueringer
Copy link
Member

sbueringer commented Dec 27, 2024

@swarren83 Are you sure about the labels on the CP Machines?

Example from e2e tests: (MD also for completeness) (https://gcsweb.k8s.io/gcs/kubernetes-ci-logs/logs/periodic-cluster-api-e2e-main/1872618404024684544/artifacts/clusters/bootstrap/resources/clusterclass-rollout-a5v7q9/)

CP: MHC + Machine

# CP MHC
  clusterName: clusterclass-rollout-rpjw07
  selector:
    matchLabels:
      cluster.x-k8s.io/control-plane: ""
      topology.cluster.x-k8s.io/owned: ""
# CP Machine
  labels:
    cluster.x-k8s.io/cluster-name: clusterclass-rollout-rpjw07
    cluster.x-k8s.io/control-plane: ""
    cluster.x-k8s.io/control-plane-name: clusterclass-rollout-rpjw07-5wm7c
    topology.cluster.x-k8s.io/owned: ""

MD: MHC + Machine

# MD MHC
  clusterName: clusterclass-rollout-rpjw07
  selector:
    matchLabels:
      topology.cluster.x-k8s.io/deployment-name: md-0
      topology.cluster.x-k8s.io/owned: ""
# MD Machine
  labels:
    cluster.x-k8s.io/cluster-name: clusterclass-rollout-rpjw07
    cluster.x-k8s.io/deployment-name: clusterclass-rollout-rpjw07-md-0-w5v9l
    cluster.x-k8s.io/set-name: clusterclass-rollout-rpjw07-md-0-w5v9l-nqqkj
    machine-template-hash: 1319028294-nqqkj
    topology.cluster.x-k8s.io/deployment-name: md-0
    topology.cluster.x-k8s.io/owned: ""

That being said. These are the labels that KCP sets. Makes me wonder what control plane provider Rancher is using

@sbueringer
Copy link
Member

cc @alexander-demicev

@swarren83
Copy link
Author

Is spec.controlplane.metadata required in order to apply the topology.cluster.x-k8s.io/ labels and annotations?

    metadata:
      annotations:
        ClusterClass.controlPlane.annotation: ClusterClass.controlPlane.annotationValue
      labels:
        ClusterClass.controlPlane.label: ClusterClass.controlPlane.labelValue

@swarren83
Copy link
Author

I also opened rancher/cluster-api-provider-rke2#517 on the rke2 provider. CAPI appears to be working as expected, based on your e2e output, but rke2 might be the culprit. If you could address my labels/annotations question above, I would be happy to close this.

@sbueringer
Copy link
Member

Is spec.controlplane.metadata required in order to apply the topology.cluster.x-k8s.io/ labels and annotations?

    metadata:
      annotations:
        ClusterClass.controlPlane.annotation: ClusterClass.controlPlane.annotationValue
      labels:
        ClusterClass.controlPlane.label: ClusterClass.controlPlane.labelValue

No, it's not required.

The following happens

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-priority Indicates an issue lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
None yet
Development

No branches or pull requests

3 participants