Node Driver Registrar

repository·master·Indexed 41 days ago

https://github.com/kubernetes-csi/node-driver-registrar

A sidecar container that automates the registration of CSI drivers with the Kubelet plugin registration mechanism. It manages registration and CSI driver UNIX domain sockets to ensure Kubelet knows which socket to use for CSI operations. Supports Linux and Windows nodes, providing features such as HTTP health checks via /healthz, a kubelet-registration-probe mode, and structured logging.

Tokens
4.9K
Snippets
8
Records
37
Agent score
50%

What's inside Node Driver Registrar

  1. What is the node-driver-registrar and how does it work?

    master

    The node-driver-registrar is a sidecar container used to register a CSI driver with the Kubelet using the Kubernetes device plugin registration mechanism.

    Because Kubelet is responsible for issuing CSI calls like NodeGetInfo, NodeStageVolume, and NodePublishVolume, the registrar must tell Kubelet which Unix domain socket to use for these interactions. It achieves this by creating a Registration socket and exposing it to Kubelet via a hostPath volume.

  2. Structured and Contextual Logging in Node Driver Registrar

    master

    Starting with version v2.11.0, the Node Driver Registrar supports both structured logging and contextual logging.

    Note: Activating structured logging changes the format of log messages. If you have automated log parsing or monitoring tools that rely on specific string patterns, you may need to update them to accommodate the new structured format.

  3. Understand the two UNIX domain sockets used by node-driver-registrar

    master

    The registrar manages two distinct sockets:

    1. Registration socket:

      • Purpose: Registers the driver with Kubelet.
      • Created by: The node-driver-registrar.
      • Location: Exposed on the node via a hostPath in the Kubelet plugin registry (typically /var/lib/kubelet/plugins_registry/<drivername.example.com>-reg.sock).
      • Requirement: The hostPath volume must be mounted at /registration inside the container.
    2. CSI driver socket:

      • Purpose: Used by Kubelet to interact with the CSI driver.
      • Created by: The CSI driver itself.
      • Location: Exposed on the node via a hostPath (typically /var/lib/kubelet/plugins/<drivername.example.com>/csi.sock).
      • Requirement: This path must be provided to the registrar via the --csi-address (internal container path) and --kubelet-registration-path (host path) arguments.
  4. Use HTTP health checks for node-driver-registrar

    master

    If you provide the --http-endpoint argument (e.g., :8080), the registrar starts an HTTP server. You can use the /healthz endpoint in a Kubernetes livenessProbe or readinessProbe. The endpoint returns a status indicating whether the registration socket exists.

    # Example livenessProbe configuration
    livenessProbe:
      httpGet:
        path: /healthz
        port: 8080
      initialDelaySeconds: 5
      timeoutSeconds: 5
  5. Upgrade requirements for node-driver-registrar on Windows

    master

    When upgrading to node-driver-registrar v2.9.0 or newer, users running on Windows must ensure their Kubernetes cluster version supports fixed handling of registration sockets. This is required because the deprecated kubelet-registration-probe and its related code have been removed.

    Required Kubernetes versions for Windows:

    • v1.23.10
    • v1.24.4
    • v1.25.0
    • Any newer version

    Note for Linux users: There are no changes to requirements for Linux; Kubernetes v1.13 remains the minimum supported version.

  6. Use exec probes to check registration status

    master

    You can use the registrar as a probe to detect if Kubelet plugin registration succeeded. This is useful for detecting if registration has stuck. To do this, set --mode=kubelet-registration-probe. In this mode, --csi-address is not required, but --kubelet-registration-path must match the path used in the container args.

    # Linux Example
    containers:
      - name: csi-driver-registrar
        image: k8s.gcr.io/sig-storage/csi-node-driver-registrar:v2.5.0
        args:
          - "--v=5"
          - "--csi-address=/csi/csi.sock"
          - "--kubelet-registration-path=/var/lib/kubelet/plugins/<drivername.example.com>/csi.sock"
        livenessProbe:
          exec:
            command:
            - /csi-node-driver-registrar
            - --kubelet-registration-path=/var/lib/kubelet/plugins/<drivername.example.com>/csi.sock
            - --mode=kubelet-registration-probe
          initialDelaySeconds: 30
          timeoutSeconds: 15