GithubHelp home page GithubHelp logo

Comments (3)

ad-zsolt-imre avatar ad-zsolt-imre commented on August 29, 2024

I refactored NodePublishVolume method of csi-lib to be able to unit test specifically the volume mounting which helped to reproduce the issue in other envs. Indeed, the issue happens when the targetPath for the volume is a non-existing directory on a read-only file system.

Given that:

  1. The CSI driver is running inside a container with a read-only filesystem (see yaml snippet below)
  2. The /mnt directory does not exist inside the cert-manager-csi-driver container
  3. For some unknown reason the request has targetPath set to /mnt for some (yet) unknown reason

The MkdirAll instruction will return with a permission error.

        - name: cert-manager-csi-driver
          securityContext:
            readOnlyRootFilesystem: true

Removing the read-only flag from the rootfs of the cert-manager-csi-driver container is obviously not a good idea. Thus, the only thing there is moving forward is figuring out where /mnt coming from and why...

from csi-driver.

ad-zsolt-imre avatar ad-zsolt-imre commented on August 29, 2024

I think I found where /mnt is coming from. MkdirAll creates directories recursively, but in case of an error, e.g. permission issue, it will only report the first directory it failed. E.g. if targetPath is /mnt/data/kubelet/... and /mnt does not exist and it's a read-only FS, it will throw a permission error with message mkdir /mnt: read-only file system.

I logged onto the node and cd'd into the csi driver's root FS at /run/k3s/containerd/io.containerd.runtime.v2.task/k8s.io/1f27f2ae202e7c4eb9037b48a2a4701df6b8ab7f03c9d97c2b9a0b4baf5d9cca/rootfs and created the /mnt directory. Then, started a pod and saw this time it was complaining about /mnt/data. Now that directory was indeed familiar to me.

ls -ld /var/lib/kubelet/pods
lrwxrwxrwx 1 root root 22 Apr 21 20:29 /var/lib/kubelet/pods -> /mnt/data/kubelet/pods
$ helm template jetstack/cert-manager-csi-driver
     ...
      volumes:
        - name: plugin-dir
          hostPath:
            path: /var/lib/kubelet/plugins/cert-manager-csi-driver
            type: DirectoryOrCreate
        - name: pods-mount-dir
          hostPath:
            path: /var/lib/kubelet/pods
            type: Directory
        - name: registration-dir
          hostPath:
            path: /var/lib/kubelet/plugins_registry
            type: Directory

All the volume dirs under /var/lib/kubelet/ live under /mnt/data in my environment has an external hard drive mounted dedicated to k3s pods.

/mnt/data on the node is not read-only. Setting readOnlyRootFilesystem to false (for testing purposes only) on the cert-manager-csi-driver container resolved the mounting problem. (However, the mounted filesystem is empty, it does not contain anything)

from csi-driver.

ad-zsolt-imre avatar ad-zsolt-imre commented on August 29, 2024

The solution was to not to symlink directories but mount the external drive to /var/lib/kubelet directly.

from csi-driver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.