dhi.io/kai-scheduler-nodescaleadjuster
Kubernetes controller that creates placeholder GPU pods so the cluster autoscaler adds nodes for unschedulable KAI Scheduler fractional-GPU pods.
All examples in this guide use the public image. If you've mirrored the repository for your own use (for example, to your Docker Hub namespace), update your commands to reference the mirrored image instead of the public one.
For example:
dhi.io/kai-scheduler-nodescaleadjuster:<tag><your-namespace>/dhi-kai-scheduler-nodescaleadjuster:<tag>For the examples, you must first use docker login dhi.io to authenticate to the registry to pull the images.
The node scale adjuster is the KAI Scheduler component that lets a cluster autoscaler add GPU nodes for pods that request a fraction of a GPU. The KAI Scheduler operator deploys it when cluster autoscaling is enabled, so you normally run this image as part of a KAI Scheduler installation rather than on its own. Upstream documentation is at https://github.com/kai-scheduler/KAI-scheduler.
Use the image line that matches your KAI Scheduler release: 0.19, 0.18, 0.16, 0.14, or 0.12. The tags
0.19.0, 0.19, and 0 are the Debian 13 runtime image. Alpine 3.24 tags carry -alpine3.24, for example
0.19.0-alpine3.24.
The entrypoint is /workspace/app, the same as upstream, and the image sets no command. Arguments that you pass to
docker run are flags for the controller. Runtime tags run as user 65532 and contain no shell. There is no version
flag.
docker run --rm dhi.io/kai-scheduler-nodescaleadjuster:<tag> --help
Outside a cluster, the controller reads a kubeconfig. The file must be readable by user 65532, and its API server
address must be reachable from the container.
docker run --rm -p 8080:8080 \
-v "$HOME/.kube/config:/kube/config:ro" \
dhi.io/kai-scheduler-nodescaleadjuster:<tag> \
--kubeconfig /kube/config \
--scheduler-name kai-scheduler \
--scaling-pod-image ghcr.io/kai-scheduler/kai-scheduler/scalingpod:v0.19.0 \
--scale-adjust-namespace kai-scale-adjust
The controller serves Prometheus metrics on port 8080, which the image declares, at http://localhost:8080/metrics.
The kai-scale-adjust namespace and the scaling pod service account (--scaling-pod-service-account, default
scaling-pod) must exist before the controller can create scaling pods.
| Flag | Purpose |
|---|---|
--scheduler-name | Only pods with this schedulerName are handled. Default kai-scheduler. |
--scaling-pod-image | Image for the placeholder scaling pods. Use the upstream scalingpod image of your release. |
--scale-adjust-namespace | Namespace where scaling pods are created. Default kai-scale-adjust. |
--scaling-pod-service-account | Service account for scaling pods. Default scaling-pod. |
--gpu-memory-to-fraction-ratio | Ratio used to convert GPU memory requests to GPU fractions. Default 0.1. |
--leader-elect | Enables leader election when you run more than one replica. |
--fips-only | Sets GODEBUG=fips140=only on scaling pods. Available on 0.18 and 0.19 only. |
The KAI Scheduler Helm chart takes one registry, global.registry, for every component, so chart values alone can't
point only the node scale adjuster at dhi.io. The operator reads the image of each component from the kai-config
Config resource, so you set this image there after the install. These steps use chart v0.19.0.
Create the namespace and a pull secret for dhi.io.
kubectl create namespace kai-scheduler
kubectl -n kai-scheduler create secret docker-registry dhi-pull-secret \
--docker-server=dhi.io --docker-username=<username> --docker-password=<token>
Install KAI Scheduler with cluster autoscaling enabled, which is what deploys the node scale adjuster.
global.securityContext applies to every KAI container. The operator defaults it to runAsUser: 10000, and this
image also runs under that user. Set 65532 to run as the image's own nonroot user.
helm upgrade -i kai-scheduler oci://ghcr.io/kai-scheduler/kai-scheduler/kai-scheduler \
--version v0.19.0 --namespace kai-scheduler \
--set global.clusterAutoscaling=true \
--set 'global.imagePullSecrets[0].name=dhi-pull-secret' \
--set global.securityContext.runAsUser=65532 \
--set global.securityContext.runAsNonRoot=true
Point the node scale adjuster at this image. Use a runtime tag; the -dev tags run as root and runAsNonRoot
rejects them.
kubectl patch configs.kai.scheduler kai-config --type merge \
-p '{"spec":{"nodeScaleAdjuster":{"service":{"image":{"repository":"dhi.io","name":"kai-scheduler-nodescaleadjuster","tag":"0.19.0"}}}}}'
kubectl -n kai-scheduler rollout status deployment/node-scale-adjuster
Every helm upgrade re-applies the chart's image settings to kai-config and switches the component back to the
upstream image, so run the patch again after each upgrade. Chart v0.19.0 creates the kai-scale-adjust namespace only
on install, so the first upgrade deletes it, and the operator can't update the node scale adjuster until it exists
again. Helm deletes the namespace in the background, so it can still be terminating when helm upgrade returns. Before
you run the patch, wait for a terminating namespace to disappear, then recreate it:
if [ "$(kubectl get namespace kai-scale-adjust -o jsonpath='{.status.phase}' 2>/dev/null)" = "Terminating" ]; then
kubectl wait --for=delete namespace/kai-scale-adjust --timeout=10m
fi
kubectl create namespace kai-scale-adjust --dry-run=client -o yaml | kubectl apply -f -
If the namespace is not terminating, the check skips the wait and the kubectl apply leaves the existing namespace as
it is. A first install is unaffected: run the install and patch steps above as written.
The operator retries with a backoff, so the new rollout can take a few minutes to start. To select a FIPS image, put the
-fips tag in the patch, for example 0.19.0-fips. global.fipsMode adds the suffix only to the tags that the chart
renders.
The operator keeps the upstream scalingpod image for the scaling pods, and creates the kai-scale-adjust service
account they use in the kai-scale-adjust namespace.
If you manage the controller yourself, the operator's container spec is a working starting point. The pod's service
account needs the permissions of the upstream kai-node-scale-adjuster ClusterRole: create, delete, get, list,
patch, update and watch on pods, get, patch and update on pods/status, create, patch and update on
events and pods/finalizers, and the same verbs as pods on leases in coordination.k8s.io.
containers:
- name: node-scale-adjuster
image: dhi.io/kai-scheduler-nodescaleadjuster:0.19.0
args:
- --scheduler-name
- kai-scheduler
- --scaling-pod-service-account
- kai-scale-adjust
- --scaling-pod-image
- ghcr.io/kai-scheduler/kai-scheduler/scalingpod:v0.19.0
- --scale-adjust-namespace
- kai-scale-adjust
ports:
- name: metrics
containerPort: 8080
securityContext:
runAsUser: 65532
runAsNonRoot: true
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
A pod that uses KAI Scheduler and requests a GPU fraction gets a scaling pod while it's unschedulable. On a cluster with
no free GPU, this pod stays pending in the default namespace:
apiVersion: v1
kind: Pod
metadata:
name: gpu-fraction-demo
labels:
kai.scheduler/queue: default-queue
annotations:
gpu-fraction: "0.5"
spec:
schedulerName: kai-scheduler
containers:
- name: main
image: dhi.io/busybox:1
command: ["sleep", "3600"]
kubectl apply -f gpu-fraction-demo.yaml
kubectl -n kai-scale-adjust get pods
The scaling pod is named <namespace>-<pod>, here default-gpu-fraction-demo, and requests one whole nvidia.com/gpu
so the cluster autoscaler adds a GPU node. The controller deletes it when the original pod is scheduled or deleted.
kubectl -n kai-scheduler port-forward deployment/node-scale-adjuster 8080:8080
In a second terminal, curl -s http://localhost:8080/metrics lists the controller-runtime metrics, for example
controller_runtime_reconcile_total. The controller has no health endpoint.
/workspace/app is a symlink to /usr/bin/nodescaleadjuster, which is also on PATH as
nodescaleadjuster. Upstream ships the binary itself at /workspace/app. To copy the binary into another image, copy
/usr/bin/nodescaleadjuster.COPYRIGHT and NOTICE in /workspace. This image ships them with LICENSE under
/usr/share/licenses/.65532, the same as upstream. The -dev tags run as root.-dev tags add bash, coreutils, findutils, and the
package manager (apk on Alpine, apt on Debian) for debugging and multi-stage builds.-fips and -fips-dev tags build the controller with the Go FIPS 140-3 cryptographic module, with fips140=on
as the default runtime setting. They also include the OpenSSL FIPS provider.0.12 and 0.14, where upstream publishes no FIPS image. For example:
0.19.0-fips (Debian 13), 0.19.0-alpine3.24-fips, and 0.14.14-alpine3.24-fips-dev.Docker Hardened Images come in different variants depending on their intended use. Image variants are identified by their tag.
Runtime variants are designed to run your application in production. These images are intended to be used either directly or as the FROM image in the final stage of a multi-stage build. These images typically:
Build-time variants typically include dev in the tag name and are intended for use in the first stage of a
multi-stage Dockerfile. These images typically:
FIPS variants include fips in the variant name and tag. They come in both runtime and build-time variants. These
variants use cryptographic modules that have been validated under FIPS 140, a U.S. government standard for secure
cryptographic operations. For example, usage of MD5 fails in FIPS variants.
To view the image variants and get more information about them, select the Tags tab for this repository, and then select a tag.
To migrate your application to a Docker Hardened Image, you must update your Dockerfile. At minimum, you must update the base image in your existing Dockerfile to a Docker Hardened Image. This and a few other common changes are listed in the following table of migration notes.
| Item | Migration note |
|---|---|
| Base image | Replace your base images in your Dockerfile with a Docker Hardened Image. |
| Package management | Non-dev images, intended for runtime, don't contain package managers. Use package managers only in images with a dev tag. |
| Non-root user | By default, non-dev images, intended for runtime, run as the nonroot user. Ensure that necessary files and directories are accessible to the nonroot user. |
| Multi-stage build | Utilize images with a dev tag for build stages and non-dev images for runtime. For binary executables, use a static image for runtime. |
| TLS certificates | Docker Hardened Images contain standard TLS certificates by default. There is no need to install TLS certificates. |
| Ports | Non-dev hardened images run as a nonroot user by default. As a result, applications in these images can't bind to privileged ports (below 1024) when running in Kubernetes or in Docker Engine versions older than 20.10. To avoid issues, configure your application to listen on port 1025 or higher inside the container. |
| Entry point | Docker Hardened Images may have different entry points than images such as Docker Official Images. Inspect entry points for Docker Hardened Images and update your Dockerfile if necessary. |
| No shell | By default, non-dev images, intended for runtime, don't contain a shell. Use dev images in build stages to run shell commands and then copy artifacts to the runtime stage. |
The following steps outline the general migration process.
Find hardened images for your app.
A hardened image may have several variants. Inspect the image tags and find the image variant that meets your needs.
Update the base image in your Dockerfile.
Update the base image in your application's Dockerfile to the hardened image you found in the previous step. For
framework images, this is typically going to be an image tagged as dev because it has the tools needed to install
packages and dependencies.
For multi-stage Dockerfiles, update the runtime image in your Dockerfile.
To ensure that your final image is as minimal as possible, you should use a multi-stage build. All stages in your
Dockerfile should use a hardened image. While intermediary stages will typically use images tagged as dev, your
final runtime stage should use a non-dev image variant.
Install additional packages
Docker Hardened Images contain minimal packages in order to reduce the potential attack surface. You may need to install additional packages in your Dockerfile. Inspect the image variants to identify which packages are already installed.
Only images tagged as dev typically have package managers. You should use a multi-stage Dockerfile to install the
packages. Install the packages in the build stage that uses a dev image. Then, if needed, copy any necessary
artifacts to the runtime stage that uses a non-dev image.
For Alpine-based images, you can use apk to install packages. For Debian-based images, you can use apt-get to
install packages.
The following are common issues that you may encounter during migration.
The hardened images intended for runtime don't contain a shell nor any tools for debugging. The recommended method for debugging applications built with Docker Hardened Images is to use Docker Debug to attach to these containers. Docker Debug provides a shell, common debugging tools, and lets you install other tools in an ephemeral, writable layer that only exists during the debugging session.
By default image variants intended for runtime, run as the nonroot user. Ensure that necessary files and directories are accessible to the nonroot user. You may need to copy files to different directories or change permissions so your application running as the nonroot user can access them.
Non-dev hardened images run as a nonroot user by default. As a result, applications in these images can't bind to
privileged ports (below 1024) when running in Kubernetes or in Docker Engine versions older than 20.10. To avoid issues,
configure your application to listen on port 1025 or higher inside the container, even if you map it to a lower port on
the host. For example, docker run -p 80:8080 my-image will work because the port inside the container is 8080, and
docker run -p 80:81 my-image won't work because the port inside the container is 81.
By default, image variants intended for runtime don't contain a shell. Use dev images in build stages to run shell
commands and then copy any necessary artifacts into the runtime stage. In addition, use Docker Debug to debug containers
with no shell.
Docker Hardened Images may have different entry points than images such as Docker Official Images. Use docker inspect
to inspect entry points for Docker Hardened Images and update your Dockerfile if necessary.