Skip to content

Commit

Permalink
fix: Use infraClient create DataVolume for external cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
scuzhanglei committed Apr 19, 2023
1 parent 8cac0f5 commit ef6b2d6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions controllers/virtinkmachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down
18 changes: 18 additions & 0 deletions docs/external-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ef6b2d6

Please sign in to comment.