This plugin integrates Longhorn, a cloud-native distributed block storage system for Kubernetes, into the Headlamp UI. It provides visibility into your Longhorn storage resources directly within Headlamp.
Longhorn provides persistent storage for Kubernetes workloads, but managing and monitoring its components (Volumes, Nodes, Backups, etc.) often requires using the separate Longhorn UI or kubectl
. This Headlamp plugin aims to bring essential Longhorn resource details and status directly into your primary Kubernetes dashboard, streamlining storage management workflows.
This plugin currently supports viewing the following Longhorn resources:
- Volumes: List view and detailed view showing status, configuration, Kubernetes PV/PVC links, and conditions.
- Nodes: List view and detailed view displaying status (Ready, Schedulable), configuration, attached disk details (including status and specs in a table), and conditions.
- Settings: A grouped view (categorized based on Longhorn documentation) displaying current setting values and their applied status.
- Backups: List view and detailed view showing state, snapshot info, target, size, timestamps, labels, and error messages.
- Engine Images: List view and detailed view displaying state, image reference, version details, node deployment status, and conditions.
- Headlamp: You need a running instance of Headlamp (either the desktop app or deployed in-cluster).
- Longhorn: Longhorn must be installed and running in the Kubernetes cluster that Headlamp is connected to.
- Navigate to the "Plugins" section in Headlamp.
- Find the "Longhorn" plugin in the catalog. (Note: This assumes the plugin is published to a catalog Headlamp uses).
- Click "Install".
- Reload Headlamp when prompted.
- Build the plugin to get the
main.js
file (and potentially other assets in thedist
directory). - Create the plugin directory structure:
- Linux:
~/.config/Headlamp/plugins/headlamp-longhorn/
- macOS:
~/Library/Application Support/Headlamp/plugins/headlamp-longhorn/
- Windows:
%APPDATA%\Headlamp\config\plugins\headlamp-longhorn\
- Linux:
- Copy the contents of the plugin's
dist
folder (includingmain.js
) and thepackage.json
file into theheadlamp-longhorn
directory created above. - Restart Headlamp.
To use this plugin in an in-cluster Headlamp deployment (when using the official Headlamp image), you need an initContainer to copy the plugin files into a shared volume mounted by the main Headlamp container.
If you followed the steps in "Advanced: Building a Plugin-Files Image" below, you can use your built image. Modify your Headlamp Helm values.yaml
or Deployment manifest:
# Example using Helm values.yaml
# Add this under the main 'headlamp' deployment configuration
initContainers:
- name: init-longhorn-plugin # Changed name slightly
# Use the image containing your built plugin files
# Ensure this image name matches the one you built/is built by CI
image: ghcr.io/giantswarm/headlamp-longhorn:latest
imagePullPolicy: Always
command:
- /bin/sh
- -c
- |
echo "Copying Longhorn plugin..."
# The target directory name MUST match how Headlamp expects to find the plugin
PLUGIN_TARGET_DIR="/headlamp/plugins/headlamp-longhorn"
mkdir -p "$PLUGIN_TARGET_DIR"
# Adjust source path inside the plugin image if necessary (should be /plugins/headlamp-longhorn based on Dockerfile)
cp -r /plugins/headlamp-longhorn/* "$PLUGIN_TARGET_DIR/"
echo "Longhorn plugin copied."
volumeMounts:
- name: plugins # Must match the volume name used by the main Headlamp container
mountPath: /headlamp/plugins
# Ensure the corresponding volumeMount is also present in the main Headlamp container
# spec:
# template:
# spec:
# containers:
# - name: headlamp
# image: ghcr.io/headlamp-k8s/headlamp:latest # Official Headlamp image
# volumeMounts:
# - name: plugins
# mountPath: /headlamp/plugins
# # ... other headlamp container config ...
# volumes:
# - name: plugins
# emptyDir: {}
Once installed and Headlamp is connected to a cluster with Longhorn running:
- Look for the Longhorn entry in the main sidebar menu on the left.
- Click on it to expand the sub-menu containing Volumes, Nodes, Settings, Backups, and Engine Images.
- Navigate through the different list and detail views.
Instead of installing the plugin manually, you can build a container image that contains just the necessary files for this plugin (dist/
directory and package.json
). This image can then be used with an initContainer (as shown in the In-Cluster Deployment section) to copy the plugin into your main Headlamp deployment.
-
Create a Dockerfile: Place the following
Dockerfile
in the root of theheadlamp-longhorn
plugin directory:# Dockerfile # Stage 1: Build the headlamp-longhorn plugin FROM node:20-alpine as builder # Set the working directory WORKDIR /plugin # Copy package files and install dependencies COPY package*.json ./ RUN npm install # Copy the rest of the plugin source code COPY . . # Build the plugin using the headlamp-plugin tool # This creates the necessary files in the /plugin/dist directory RUN npm run build # Stage 2: Create the final image containing only the built plugin artifacts FROM alpine:latest # Create the directory structure expected by Headlamp (/plugins/<plugin-folder-name>) # Using 'headlamp-longhorn' as the folder name based on repo/directory structure RUN mkdir -p /plugins/headlamp-longhorn # Copy the built plugin files (dist/) and package.json from the builder stage COPY --from=builder /plugin/dist/ /plugins/headlamp-longhorn/ COPY --from=builder /plugin/package.json /plugins/headlamp-longhorn/ # Optional: Set permissions if needed, though typically handled by volume mounts/Headlamp itself # RUN chown -R <someuser>:<somegroup> /plugins # No CMD or ENTRYPOINT needed, this image just holds files.
-
Build the image: Run this command from the root of the
headlamp-longhorn
plugin directory:# Build the image containing only the plugin files docker build -t ghcr.io/giantswarm/headlamp-longhorn:my-tag .
(Replace
my-tag
with your desired image tag, e.g.,latest
or a version number). -
Push the image: (If needed for your cluster)
# Push the image containing only the plugin files docker push ghcr.io/giantswarm/headlamp-longhorn:my-tag
This image can now be referenced in an initContainer as shown in the In-Cluster Deployment section.
Note: An image containing just the plugin files is automatically built and pushed to ghcr.io/giantswarm/headlamp-longhorn
by a GitHub Actions workflow whenever changes are pushed to the main
branch or a version tag (e.g., v1.x.x
) is created.
To run this plugin locally during development:
- Clone the repository.
- Navigate to the plugin directory (
cd headlamp-longhorn
). - Install dependencies:
npm install
- Start the development server:
npm run start
- Ensure Headlamp (desktop app recommended for development) is running and configured to load plugins from the appropriate directory or that you manually copy the built files to its plugin directory.
Encountered a bug or have a feature request? Please file an issue on the GitHub repository.