From ef6b2d6d3cdd6a7f711f075c8f58f949088491eb Mon Sep 17 00:00:00 2001 From: zhanglei Date: Tue, 18 Apr 2023 16:36:38 +0800 Subject: [PATCH] fix: Use infraClient create DataVolume for external cluster --- controllers/virtinkmachine_controller.go | 4 ++-- docs/external-cluster.md | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/controllers/virtinkmachine_controller.go b/controllers/virtinkmachine_controller.go index d0dc859..6e8f75f 100644 --- a/controllers/virtinkmachine_controller.go +++ b/controllers/virtinkmachine_controller.go @@ -209,7 +209,7 @@ func (r *VirtinkMachineReconciler) reconcile(ctx context.Context, machine *infra } dataVolumeNotFound := false createdDataVolume := cdiv1beta1.DataVolume{} - if err := r.Get(ctx, dataVolumeKey, &createdDataVolume); err != nil { + if err := infraClusterClient.Get(ctx, dataVolumeKey, &createdDataVolume); err != nil { if !apierrors.IsNotFound(err) { return fmt.Errorf("get DataVolume: %s", err) } @@ -222,7 +222,7 @@ func (r *VirtinkMachineReconciler) reconcile(ctx context.Context, machine *infra Name: dataVolume.Name, } var pvc corev1.PersistentVolumeClaim - if err := r.Get(ctx, pvcKey, &pvc); err != nil { + if err := infraClusterClient.Get(ctx, pvcKey, &pvc); err != nil { if !apierrors.IsNotFound(err) { return fmt.Errorf("get PVC: %s", err) } diff --git a/docs/external-cluster.md b/docs/external-cluster.md index 64992a2..a825623 100644 --- a/docs/external-cluster.md +++ b/docs/external-cluster.md @@ -52,6 +52,24 @@ subjects: EOF ``` +for creating a persistent cluster, should follow [Launching a Kubernetes cluster on Virtink with persistent storage](./../README.md) to make Virtink cluster meets the conditions, and add below rule to virtink-infra-cluster ClusterRole. + +```yaml +rules: +- apiGroups: + - cdi.kubevirt.io + resources: + - datavolumes + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +``` + Create a kubeconfig with API access control of the Virtink cluster. ```shell