A kubectl plugin for creating LimitRange resources with specified CPU and memory limits in Kubernetes namespaces.
This plugin provides a command-line interface for easily creating LimitRange resources in your Kubernetes cluster. It extends the kubectl create command to support creating LimitRange resources directly. It supports both client-side and server-side dry runs and outputs in YAML or JSON formats for previewing the resource before creation.
- Create
LimitRangeresources with configurable CPU and memory limits. - Supports dry-run modes (
clientandserver) to preview the resource without applying it. - Outputs resource definitions in YAML or JSON format.
- Easy to use with intuitive command flags.
Ensure you have Go installed and kubectl configured on your system. Clone this repository and run:
go build cmd/kubectl-create-lr/kubectl-create-limitrange.goMove the binary to a directory in your PATH:
mv kubectl-create-limitrange /usr/local/bin/go test ./pkg/cmd/... -vkubectl create limitrange my-limitrange --namespace=my-namespace --max-cpu="1" --min-cpu=100m --max-memory=500Mi --min-memory=100Mikubectl create limitrange my-limitrange --namespace=my-namespace --max-cpu="2" --dry-run=client -o yamlkubectl create limitrange my-limitrange --namespace=my-namespace --max-cpu="1" --dry-run=server -o jsonkubectl create limitrange my-limitrange --namespace=my-namespace --max-cpu="1" --min-cpu=100m --max-memory=500Mi --min-memory=100Mi--max-cpu: Maximum CPU limit for containers.--min-cpu: Minimum CPU limit for containers.--default-cpu: Default CPU limit for containers.--default-request-cpu: Default CPU request for containers.--max-memory: Maximum memory limit for containers.--min-memory: Minimum memory limit for containers.-n, --namespace: Namespace for thelimitrangeresource (shorthand for--namespace).--dry-run: Dry-run mode (clientorserver).-o, --output: Output format (yamlorjson).
-
Create a
limitrangewith CPU and memory limits:kubectl create limitrange my-limitrange --namespace=my-namespace --max-cpu="1" --min-cpu=100m --max-memory=500Mi --min-memory=100Mi -
Client-side dry-run:
kubectl create limitrange my-limitrange --namespace=my-namespace --max-cpu="2" --min-cpu=500m --dry-run=client -o yaml -
Server-side dry-run:
kubectl create limitrange my-limitrange --namespace=my-namespace --default-cpu=500m --default-request-cpu=200m --dry-run=server -o json
- Go 1.24 or later.
kubectlconfigured on your system.
Feel free to contribute by submitting issues or pull requests. Any help to enhance the functionality or add new features is welcome!


