loft-sh / vcluster

vCluster - Create fully functional virtual Kubernetes clusters - Each vcluster runs inside a namespace of the underlying k8s cluster. It's cheaper than creating separate full-blown clusters and it offers better multi-tenancy and isolation than regular namespaces.
https://www.vcluster.com
Apache License 2.0
6.92k stars 427 forks source link

Syncer can't find PV on reconcile. #2183

Closed emoreth closed 1 month ago

emoreth commented 2 months ago

What happened?

Syncer keeps erroring when reconciling PV even when it works.

What did you expect to happen?

The syncer not to raise errors.

How can we reproduce it (as minimally and precisely as possible)?

Assuming AWS, create a new vcluster v0.21.0.alph1.8 and apply this

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  annotations:
    storageclass.kubernetes.io/is-default-class: "true"
  name: gp2
parameters:
  fsType: ext4
  type: gp2
provisioner: kubernetes.io/aws-ebs
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer

---

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: my-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
  storageClassName: gp2
  volumeMode: Filesystem

---

apiVersion: v1
kind: Pod
metadata:
  name: my-pod
spec:
  containers:
    - name: my-container
      image: nginx
      volumeMounts:
        - mountPath: "/usr/share/nginx/html"
          name: my-pvc-volume
  volumes:
    - name: my-pvc-volume
      persistentVolumeClaim:
        claimName: my-pvc

Even though the volume gets created, PVC is bound, pod goes up and keeps running, syncer keeps throwing this:

2024-09-26 20:55:31 ERROR   controller/controller.go:324    Reconciler error    {"component": "vcluster", "controller": "persistent-volume-claim", "namespace": "host#my-namespace", "name": "my-pvc-x-default-x-testv2", "reconcileID": "f42183d8-64f7-40f1-bec0-59bc46378dff", "error": "error retrieving virtual persistent volume pvc-dc31972a-8d0d-4f47-ad5f-2159f3ed2eab: not found"}
2024-09-26 20:56:12 INFO    persistent-volume-claim.my-pvc-x-default-x-testv2   persistentvolumeclaims/syncer.go:142    error retrieving virtual persistent volume pvc-dc31972a-8d0d-4f47-ad5f-2159f3ed2eab: not found  {"component": "vcluster"}

Also, the PVC inside the vclusters gets stuck on Pending state.

Anything else we need to know?

No response

Host cluster Kubernetes version

```console Client Version: v1.31.1 Kustomize Version: v5.4.2 Server Version: v1.29.7-eks-a18cd3a ```

vcluster version

```console vcluster version 0.20.0 ```

VCluster Config

Adding RBAC for storageclasses is required since syncing from host is disabled, but it doesn't change the behavior.

```yaml rbac: clusterRole: extraRules: - apiGroups: - storage.k8s.io resources: - storageclasses verbs: - get - watch - list sync: fromHost: storageClasses: enabled: false toHost: ingresses: enabled: true persistentVolumeClaims: enabled: true persistentVolumes: enabled: true ```
emoreth commented 2 months ago

Adding some context: since the PVC is stuck on pending, helm install --wait ... also gets stuck waiting for the PVC since it never reaches Bound state

matskiv commented 1 month ago

This is already fixed in v0.21.0-alpha.9

emoreth commented 1 month ago

🤦

Thanks!