K8s Resource Input

Reads Kubernetes CPU and memory requests back in plain units, so 500 meaning 500 cores or 400m meaning 0.4 bytes is caught before deploy.

StopsPod asks for 500 CPU cores

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/k8s-resource-input.json

The files land in your project. They're yours to edit.

Usage

k8s-resource-input-usage.tsx
import { K8sResourceInput } from "@/components/ui/k8s-resource-input"

return <K8sResourceInput defaultValue={{ cpu: { request: "500", limit: "1" }, memory: { request: "1Gi", limit: "1G" } }} node={{ cpu: "3920m", memory: "15Gi" }} />

What it catches

  • CPU 500 meaning 500 cores
  • Memory 400m meaning 0.4 bytes, and MB/Gb style unit slips
  • A limit below its request (1G vs 1Gi)
  • CPU finer than 1m, which the API rounds
  • Requests larger than your biggest node

Props

K8sResourceInput props
PropTypeDefault
value

Controlled requests and limits for one container.

K8sResources—
defaultValue

Initial requests and limits when uncontrolled.

K8sResourcesEMPTY
onValueChange

Called with all four values on every edit, fix or YAML paste.

(value: K8sResources) => void—
node

Allocatable CPU and memory of your largest node; requests above it are flagged as never schedulable.

NodeCapacity—
messages

Every visible string. `{field}`, `{value}` and the other placeholders are filled in.

Partial<K8sResourceInputMessages>—

* required. Also accepts the native props of <fieldset> (className, aria-*, data-*…), passed through to it.

Accessibility

  • Each field has a visible label and is described by its plain-units readback
  • aria-invalid on flagged fields; status uses role=status
  • Focus returns to a nearby control after a fix

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

  • Node size comes from the node prop; it doesn't query the cluster
  • Doesn't check LimitRanges, ResourceQuotas or ephemeral storage
  • QoS class is computed for this container only, not the whole pod

Rules

Rules last verified:

Informational. Confirmed the case-sensitive suffix warning (400m of memory is 0.4 bytes). Rounding and QoS rules were not re-checked this round. Copied components don't update themselves, so re-check after rule changes (see updating a component).

What it stops

Pod asks for 500 CPU cores

Also known as

kubernetes · k8s · resources requests limits · cpu memory · millicores · Mi Gi · deployment yaml · qos class

Field type

Dependencies

Pairs well with