very simple golang container/tool for testing memory quotas and limits in kubernetes / OpenShift
2.6K
Memory quota testing tool for containers. Static Go binary, minimal size.
Memory Tester is a lightweight application designed to test memory quota limits in containers and Kubernetes/OpenShift clusters. It helps validate resource quotas and observe OOMKilled behavior when container memory allocations exceed configured limits.
CGO_ENABLED=0, single binary with no external dependenciesscratch base image - essentially zero base layer# Run with CLI flag
podman run -it bliskner/memory-tester:latest --allocate=256M
# Run with environment variable
podman run -it -e ALLOCATE=1G bliskner/memory-tester:latest
# Run with short format
podman run -it bliskner/memory-tester:latest -a 512M
trivy image --image-src podman bliskner/memory-tester:latest
2026-04-13T09:27:26+02:00 INFO [vuln] Vulnerability scanning is enabled
2026-04-13T09:27:26+02:00 INFO [secret] Secret scanning is enabled
2026-04-13T09:27:26+02:00 INFO [secret] If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2026-04-13T09:27:26+02:00 INFO [secret] Please see also https://trivy.dev/dev/docs/scanner/secret#recommendation for faster secret detection
2026-04-13T09:27:26+02:00 INFO Number of language-specific files num=1
2026-04-13T09:27:26+02:00 INFO [gobinary] Detecting vulnerabilities...
Report Summary
┌───────────────┬──────────┬─────────────────┬─────────┐
│ Target │ Type │ Vulnerabilities │ Secrets │
├───────────────┼──────────┼─────────────────┼─────────┤
│ memory-tester │ gobinary │ 0 │ - │
└───────────────┴──────────┴─────────────────┴─────────┘
Legend:
- '-': Not scanned
- '0': Clean (no security findings detected)
# Deploy with default settings
oc new-app bliskner/memory-tester:latest --name=memory-tester
# Deploy with memory allocation
oc new-app bliskner/memory-tester:latest --name=memory-tester -e ALLOCATE=256M
# Deploy with memory limits (triggers OOMKilled if allocation exceeds limit)
oc new-app bliskner/memory-tester:latest --name=memory-tester \
-e ALLOCATE=512M --limits=memory=256Mi
# Check pod status
oc get pods -l app=memory-tester
# View logs
oc logs -l app=memory-tester
# Check for OOMKilled
oc describe pod memory-tester-xxxxx | grep -A 3 "State:"
# Create deployment
kubectl create deployment memory-tester --image=bliskner/memory-tester:latest
# Set memory allocation
kubectl set env deployment/memory-tester ALLOCATE=256M
# Scale if needed
kubectl scale deployment memory-tester --replicas=1
# Edit deployment to add resource limits
kubectl edit deployment memory-tester
# Add to spec.containers[].resources:
resources:
limits:
memory: 256Mi
requests:
memory: 128Mi
# Check pod status
kubectl get pods -l app=memory-tester
# View logs
kubectl logs -l app=memory-tester
# Check for OOMKilled
kubectl describe pod memory-tester-xxxxx
OpenShift and other Kubernetes distributions run containers with random UIDs for security. The image works correctly in rootless environments:
./memory-tester --allocate=256M
./memory-tester --allocate=1G
./memory-tester -a 512M
./memory-tester --allocate=1024
ALLOCATE=256M ./memory-tester
ALLOCATE=1G ./memory-tester
CLI flags take precedence over environment variables:
ALLOCATE=1G ./memory-tester --allocate=256M
# Result: 256M will be allocated
| Format | Example | Bytes |
|---|---|---|
| Bytes | 1024 | 1,024 |
| Kilobytes | 512K, 512KB | 524,288 |
| Megabytes | 256M, 256MB | 268,435,456 |
| Gigabytes | 1G, 1GB | 1,073,741,824 |
| Terabytes | 1T, 1TB | 1,099,511,627,776 |
# Build static binary
make build
# Build container image
make image
# Run local tests
make test
# Rebuild image without cache
make clean
| Variable | Description | Default |
|---|---|---|
IMAGE_NAME | Container image name | memory-tester |
IMAGE_TAG | Container image tag | 2026-04-13 |
ALLOCATE | Memory to allocate | - |
MIT
Content type
Image
Digest
sha256:c09accf42…
Size
1.6 MB
Last updated
6 months ago
docker pull bliskner/memory-allocator