Skip to content

metal3: Add BareMetalHost plugin with list and detail views#852

Open
mastermaxx03 wants to merge 4 commits into
headlamp-k8s:mainfrom
mastermaxx03:metal3-plugin
Open

metal3: Add BareMetalHost plugin with list and detail views#852
mastermaxx03 wants to merge 4 commits into
headlamp-k8s:mainfrom
mastermaxx03:metal3-plugin

Conversation

@mastermaxx03

@mastermaxx03 mastermaxx03 commented Jun 24, 2026

Copy link
Copy Markdown

Summary

Initial Metal3 plugin. Adds a Metal3 section to Headlamp for the
BareMetalHost resource. First phase of the plugin development; more resources and a
map view to follow.

Included

  • BareMetalHost list view with a composite Status column (operational
    status, provisioning state, and error type in one cell).
  • BareMetalHost detail view (config, status, consumer, power, BMC).
  • A reusable CRD guard that shows a clear message when the Metal3 CRDs
    aren't installed in the cluster.
  • Unit tests for the status logic and a Storybook story.

How to test

  1. A cluster with the Metal3 CRDs installed.
  2. cd metal3 && npm install && npm start, then run Headlamp.
  3. Apply the sample host: kubectl apply -f metal3/test-files/baremetalhost.yaml.
  4. Open the Metal3 section: the host lists, and clicking it opens the detail view.

Scope

Read-only, BareMetalHost only for now. The cluster-api-provider-metal3
resources, the relationship map, and mutating actions are planned follow-ups.

Relates to kubernetes-sigs/headlamp#5268.

@mastermaxx03

Copy link
Copy Markdown
Author

@illume Ready for review!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an initial Metal3 plugin to the headlamp-k8s/plugins repo, introducing a new sidebar section and routes to view Metal3 BareMetalHost resources in Headlamp (list + details), along with supporting status composition logic, tests, and Storybook coverage.

Changes:

  • Register a new Metal3 sidebar entry and routes for BareMetalHost list/detail pages.
  • Implement BareMetalHost list and detail views, including a composite Status column and a reusable CRD presence guard.
  • Add unit tests + Storybook story for the status composition/rendering, plus local test YAML and plugin scaffolding files.

Reviewed changes

Copilot reviewed 13 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
metal3/tsconfig.json TypeScript config extending the standard Headlamp plugin tsconfig.
metal3/test-files/baremetalhost.yaml Sample Secret + BareMetalHost manifest for local testing.
metal3/src/storybook.test.tsx Storyshots test runner for Storybook stories in this plugin.
metal3/src/index.tsx Registers Metal3 sidebar entry and list/detail routes.
metal3/src/headlamp-plugin.d.ts Adds Headlamp plugin type references for TS.
metal3/src/common/CRDGuard.tsx Guard component to render a clear message when CRDs are missing.
metal3/src/BareMetalHost/status.tsx Composite status derivation + status cell rendering component.
metal3/src/BareMetalHost/status.test.ts Unit tests for composeStatus.
metal3/src/BareMetalHost/status.stories.tsx Storybook stories for the status label rendering.
metal3/src/BareMetalHost/List.tsx BareMetalHost list view using ResourceListView + composite Status column.
metal3/src/BareMetalHost/Details.tsx BareMetalHost detail view using DetailsGrid extraInfo fields.
metal3/README.md Plugin documentation, scope, dev workflow, and limitations.
metal3/package.json Plugin package metadata and standard headlamp-plugin scripts.
metal3/.gitignore Ignores build output, caches, editor files, node_modules.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread metal3/src/common/CRDGuard.tsx Outdated
* limitations under the License.
*/

import CustomResourceDefinition from '@kinvolk/headlamp-plugin/lib/lib/k8s/crd';
Comment thread metal3/README.md Outdated
Comment on lines +3 to +4
A [Headlamp](https://headlamp.dev) plugin that adds a Metal3 section to the UI for viewing and
managing bare-metal infrastructure through Kubernetes.

@illume illume left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one!

I left some notes.

Comment thread metal3/src/BareMetalHost/Details.tsx Outdated
import { CRDGuard } from '../common/CRDGuard';
import { bareMetalHostClass } from './List';

// Detail view for a single BareMetalHost. DetailsGrid renders the standard

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the formatting of comments in other plugins. We use tsdoc to document interfaces+fields, functions, params, return values etc.

Comment thread metal3/README.md
- A Kubernetes cluster whose API has the Metal3 `baremetal-operator` CRDs installed, in
particular `baremetalhosts.metal3.io`. If those CRDs are absent, the plugin indicates that the
operator is not installed rather than showing an empty view.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to add a link to the metal3 getting started page.

Comment thread metal3/src/BareMetalHost/status.tsx Outdated
// Renders the composite status for the list view: operational status as the
// colored headline, provisioning state beneath it, and the error type as a
// separate badge carrying the error message on hover.
export function BareMetalHostStatusLabel({ host }: { host: KubeObject }) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Component file names should the same name as the component. So perhaps rename this HostStatusLabel.tsx HostStatusLabel.stories.tsx and HostStatusLabel.test.tsx

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 15 changed files in this pull request and generated 3 comments.

Comment on lines +51 to +54
if (!crd) {
// CRD presence is still being checked.
return null;
}
Comment thread metal3/src/BareMetalHost/List.tsx Outdated

export function BareMetalHosts() {
return (
<CRDGuard crdName="baremetalhosts.metal3.io" resourceLabel="BareMetalHost">
Comment thread metal3/src/BareMetalHost/Details.tsx Outdated
const { name = params.name, namespace = params.namespace } = props;

return (
<CRDGuard crdName="baremetalhosts.metal3.io" resourceLabel="BareMetalHost">
@mastermaxx03

Copy link
Copy Markdown
Author

@illume addressed the comments!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 15 changed files in this pull request and generated 2 comments.

Comment on lines +53 to +56
<Typography variant="body2" color="textSecondary">
The {crdName} CRD was not found in this cluster. Install the corresponding Metal3 operator
to view {resourceLabel} resources here.
</Typography>
Comment thread metal3/package.json Outdated
{
"name": "@headlamp-k8s/metal3",
"version": "0.1.0",
"description": "A Headlamp plugin for viewing and managing Metal3 bare-metal hosts and infrastructure.",
Signed-off-by: mastermaxx03 <srivastavaanimesh22@gmail.com>
Signed-off-by: mastermaxx03 <srivastavaanimesh22@gmail.com>
Signed-off-by: mastermaxx03 <srivastavaanimesh22@gmail.com>
Signed-off-by: mastermaxx03 <srivastavaanimesh22@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 15 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants