metal3: Add BareMetalHost plugin with list and detail views#852
metal3: Add BareMetalHost plugin with list and detail views#852mastermaxx03 wants to merge 4 commits into
Conversation
|
@illume Ready for review! |
There was a problem hiding this comment.
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
Metal3sidebar entry and routes forBareMetalHostlist/detail pages. - Implement
BareMetalHostlist 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.
| * limitations under the License. | ||
| */ | ||
|
|
||
| import CustomResourceDefinition from '@kinvolk/headlamp-plugin/lib/lib/k8s/crd'; |
| A [Headlamp](https://headlamp.dev) plugin that adds a Metal3 section to the UI for viewing and | ||
| managing bare-metal infrastructure through Kubernetes. |
illume
left a comment
There was a problem hiding this comment.
Nice one!
I left some notes.
| import { CRDGuard } from '../common/CRDGuard'; | ||
| import { bareMetalHostClass } from './List'; | ||
|
|
||
| // Detail view for a single BareMetalHost. DetailsGrid renders the standard |
There was a problem hiding this comment.
Please check the formatting of comments in other plugins. We use tsdoc to document interfaces+fields, functions, params, return values etc.
| - 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. | ||
|
|
There was a problem hiding this comment.
I think it would be good to add a link to the metal3 getting started page.
| // 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 }) { |
There was a problem hiding this comment.
Component file names should the same name as the component. So perhaps rename this HostStatusLabel.tsx HostStatusLabel.stories.tsx and HostStatusLabel.test.tsx
| if (!crd) { | ||
| // CRD presence is still being checked. | ||
| return null; | ||
| } |
|
|
||
| export function BareMetalHosts() { | ||
| return ( | ||
| <CRDGuard crdName="baremetalhosts.metal3.io" resourceLabel="BareMetalHost"> |
| const { name = params.name, namespace = params.namespace } = props; | ||
|
|
||
| return ( | ||
| <CRDGuard crdName="baremetalhosts.metal3.io" resourceLabel="BareMetalHost"> |
69b75d2 to
5c487b8
Compare
|
@illume addressed the comments! |
| <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> |
| { | ||
| "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>
5c487b8 to
db44806
Compare
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
status, provisioning state, and error type in one cell).
aren't installed in the cluster.
How to test
cd metal3 && npm install && npm start, then run Headlamp.kubectl apply -f metal3/test-files/baremetalhost.yaml.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.