k3s-io / cluster-api-k3s

Cluster API k3s
Apache License 2.0
133 stars 38 forks source link

Visualizer could not load cluster, need to enable default webhook #110

Closed nasusoba closed 1 month ago

nasusoba commented 1 month ago

I am using cluster api visualizer to help with debugging. But I find that after upgrading to v1beta2, the visualizer could not load the cluster. It seems that the commented line must be added to fix.

apiVersion: controlplane.cluster.x-k8s.io/v1beta2
kind: KThreesControlPlane
metadata:
  name: ${CLUSTER_NAME}-control-plane
  namespace: ${NAMESPACE}
spec:
  machineTemplate:
    infrastructureRef:
      apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
      kind: DockerMachineTemplate
      name: ${CLUSTER_NAME}-control-plane
      # namespace: ${NAMESPACE}
  replicas: ${CONTROL_PLANE_MACHINE_COUNT}
  version: ${KUBERNETES_VERSION}
  kthreesConfigSpec:
    serverConfig:
      tlsSan:
        - 0.0.0.0

What kubeadm capi does is to introduce the default webhook to set the namespace if it does not present (ref). I tried with the default webhook(commit), but it seems that default webhook is not functioning?? Any idea??

nasusoba commented 1 month ago

@anmazzotti Am I missing anything for enabling default webhook? Thanks!

anmazzotti commented 1 month ago

It may be that the controller-runtime version was bumped and the API changed while the PR was opened.

I wonder if the webhooks work at all, conversion webhooks included.

Like we implement Default(), but the newer interface is Default(ctx context.Context, obj runtime.Object) error

I'll try to have a look today and see if I can prepare a PR.