HUB
Sign inSign up
Kubeflow Volumes Web App

dhi.io/kubeflow-volumes-web-app

Kubeflow Volumes Web App

CIS
FIPS
STIG
linux/amd64
linux/arm64

Web app and API for creating, browsing and deleting PersistentVolumeClaims in Kubeflow profile namespaces.

How to use this image

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:

  • Public image: dhi.io/kubeflow-volumes-web-app:<tag>
  • Mirrored image: <your-namespace>/dhi-kubeflow-volumes-web-app:<tag>

For the examples, you must first use docker login dhi.io to authenticate to the registry to pull the images.

Start a Kubeflow Volumes Web App image

This image is the Kubeflow Volumes Web App from the Kubeflow Notebooks project⁠. It is a Flask backend and an Angular UI that Kubeflow users open from the central dashboard to create, list, and delete PersistentVolumeClaims in their profile namespaces, and to open a file browser on a claim. The file browser is a PVCViewer resource that the web app creates and that the Kubeflow PVCViewer Controller runs. The controller is also available as a Docker Hardened Image, kubeflow-pvcviewer-controller.

The entrypoint starts gunicorn with three workers on port 5000. The image runs as uid and gid 65532. When the app starts, it loads a Kubernetes configuration: the in-cluster service account, or the file named by KUBECONFIG outside a cluster. Without either, the gunicorn worker fails to boot and the container exits.

Deploy in Kubernetes

The following overlay uses the upstream manifests/base kustomization at the v1.11.1 tag. It creates the service account, the cluster roles and binding, the parameters and viewer-spec ConfigMaps, the Service (port 80 to 5000), and the Deployment in the kubeflow namespace. The overlay replaces the upstream image with this image and runs the container as uid and gid 65532, the image's numeric user and group:

# kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - github.com/kubeflow/notebooks/components/crud-web-apps/volumes/manifests/base?ref=v1.11.1
images:
  - name: ghcr.io/kubeflow/notebooks/volumes-web-app
    newName: dhi.io/kubeflow-volumes-web-app
    newTag: 1.11.1-debian13
patches:
  - target:
      kind: Deployment
      name: volumes-web-app-deployment
    patch: |-
      - op: replace
        path: /spec/template/spec/containers/0/securityContext/runAsUser
        value: 65532
      - op: add
        path: /spec/template/spec/containers/0/securityContext/runAsGroup
        value: 65532

The base does not create the kubeflow namespace. In a Kubeflow installation it already exists; otherwise create it, then apply the overlay:

kubectl create namespace kubeflow
kubectl apply -k .

Your cluster must be able to pull from dhi.io, for example through an image pull secret.

The upstream Deployment sets runAsUser: 1000, runAsNonRoot: true, allowPrivilegeEscalation: false, and drops all capabilities. The image also starts under uid 1000, but use 65532: gunicorn opens a control socket under the user's home directory, which is /home/nonroot for 65532. Under uid 1000 the home directory is /, and gunicorn logs Control server error: [Errno 13] Permission denied: '/.gunicorn' at startup. The app still serves requests. The upstream image logs the same error under uid 1000.

In a Kubeflow installation, the Istio gateway routes /volumes/ to the Service. That route is not in manifests/base. To get it, replace manifests/base with manifests/overlays/istio in resources; this adds the VirtualService, DestinationRule, and AuthorizationPolicy, and the images and patches entries stay the same.

To check the deployment, forward the Service port:

kubectl -n kubeflow port-forward svc/volumes-web-app-service 8080:80

Then, in another terminal, list the claims in a profile namespace as a Kubeflow user. Replace alice with the user name that the central dashboard sends in the kubeflow-userid header, and kubeflow-user-example-com with a namespace that user can access:

curl -H "kubeflow-userid: alice" http://localhost:8080/api/namespaces/kubeflow-user-example-com/pvcs

The app authorizes each request with a SubjectAccessReview for that user. To list claims, the user needs list on PersistentVolumeClaims, Notebooks, and PVCViewers in the namespace. The base adds ClusterRoles that aggregate the PersistentVolumeClaim and PVCViewer permissions into the Kubeflow kubeflow-edit and kubeflow-view roles. The cluster also needs the Notebook and PVCViewer CustomResourceDefinitions that Kubeflow installs. Requests that create or delete resources also need a CSRF token: send the XSRF-TOKEN cookie, which the app sets when it serves the UI, back in an X-XSRF-TOKEN header, with Content-Type: application/json.

Users open the UI through the Kubeflow central dashboard. The page loads /dashboard_lib.bundle.js, which the central dashboard serves. The web app does not include that script. When you open the web app directly, that request returns the app's own index page instead of the script. The upstream image behaves the same way.

Run with a read-only root filesystem

To set readOnlyRootFilesystem: true, add the following entry to the patches list of the overlay. gunicorn writes worker temporary files to /tmp, so the patch mounts an emptyDir there. Without it, gunicorn fails to spawn workers and the container exits. The patch also passes --no-control-socket to gunicorn, because the read-only /home/nonroot cannot hold the control socket:

- target:
    kind: Deployment
    name: volumes-web-app-deployment
  patch: |-
    - op: add
      path: /spec/template/spec/containers/0/securityContext/readOnlyRootFilesystem
      value: true
    - op: add
      path: /spec/template/spec/containers/0/args
      value: ["--no-control-socket"]
    - op: add
      path: /spec/template/spec/containers/0/volumeMounts/-
      value: {name: tmp, mountPath: /tmp}
    - op: add
      path: /spec/template/spec/volumes/-
      value: {name: tmp, emptyDir: {}}
Run locally with Docker

To try the app outside a cluster, save a kubeconfig as kubeconfig in the current directory. The file must be readable by uid 65532, and its server address must be reachable from inside the container (127.0.0.1 refers to the container, not your host). APP_SECURE_COOKIES=false lets the browser keep the CSRF cookie over plain HTTP:

docker run -d --name volumes-web-app -p 5000:5000 \
  -v "$PWD/kubeconfig:/kube/config:ro" \
  -e KUBECONFIG=/kube/config \
  -e APP_PREFIX=/volumes \
  -e APP_SECURE_COOKIES=false \
  dhi.io/kubeflow-volumes-web-app:<tag>

The health probes and the metrics endpoint do not need a user header:

curl http://localhost:5000/healthz/readiness
curl http://localhost:5000/metrics

The UI and the API answer 401 unless the request carries the user header. The served page sets <base href> and the cookie path to APP_PREFIX:

curl -i -H "kubeflow-userid: alice" http://localhost:5000/

Remove the container when you are done:

docker rm -f volumes-web-app
Pass options to gunicorn

Arguments after the image name are appended to the gunicorn command line. gunicorn uses the last value of a repeated option, so --workers 1 replaces the default -w 3:

docker run -d --name volumes-web-app -p 5000:5000 \
  -v "$PWD/kubeconfig:/kube/config:ro" \
  -e KUBECONFIG=/kube/config \
  dhi.io/kubeflow-volumes-web-app:<tag> --workers 1 --timeout 120

In Kubernetes, set the same options in the container's args. To replace the whole command line instead, set command to /usr/lib/kubeflow-volumes-web-app/venv/bin/gunicorn with the full argument list, ending in entrypoint:app.

Environment variables

The app reads these variables. The upstream params.env sets APP_PREFIX=/volumes, an empty USERID_PREFIX, and METRICS=1, and the upstream Deployment sets VOLUME_VIEWER_IMAGE=filebrowser/filebrowser:v2.32.0.

VariableDescriptionDefault
APP_PREFIXPath the app is served under. Sets the page's <base href> and the CSRF cookie path./
USERID_HEADERRequest header that carries the user name.kubeflow-userid
USERID_PREFIXString removed from the header value to get the user name.:
APP_SECURE_COOKIESMarks the CSRF cookie Secure. Set to false only for plain-HTTP testing.true
CSRF_SAMESITESameSite attribute of the CSRF cookie: Strict, Lax, or None.Strict
METRICSServes Prometheus metrics at /metrics. Only an empty value turns metrics off; 0 and false leave them on.on
VOLUME_VIEWER_IMAGEReferenced as $VOLUME_VIEWER_IMAGE by the upstream viewer template to set the file browser image.not set
KUBECONFIGKubeconfig file to use when the app runs outside a cluster.not set

The app builds each PVCViewer from the template at /etc/config/viewer-spec.yaml. Neither this image nor the upstream image contains that file; the upstream base mounts it from the viewer-spec ConfigMap. Without it, creating a viewer fails with HTTP 500 and the log shows FileNotFoundError: [Errno 2] No such file or directory: '/etc/config/viewer-spec.yaml'.

Non-hardened images vs. Docker Hardened Images

  • Entrypoint and arguments. The upstream entrypoint is /bin/bash -c "gunicorn -w 3 --bind 0.0.0.0:5000 ...", so upstream ignores container arguments. This image runs /usr/lib/kubeflow-volumes-web-app/venv/bin/gunicorn -w 3 --bind 0.0.0.0:5000 --access-logfile - entrypoint:app directly and appends container arguments to it. Kubernetes args that had no effect on the upstream image now reach gunicorn, so remove any you did not intend. A command that starts /bin/bash fails, because runtime images have no shell. See Pass options to gunicorn⁠.
  • User. The upstream image runs as root, and the upstream Deployment sets uid 1000. This image runs as the nonroot user, uid and gid 65532. See Deploy in Kubernetes⁠ for the security context to use.
  • Ports. The image declares 5000/tcp. The upstream image declares no ports, but the app listens on 5000 in both.
  • Python. Python 3.12 and the app's dependencies are in a virtual environment at /usr/lib/kubeflow-volumes-web-app/venv, whose bin directory is first on PATH, so python and gunicorn resolve there. /src, the working directory, links to the app at /usr/lib/kubeflow-volumes-web-app/src. pip is not included in any variant. The upstream image's PYTHON_VERSION, PYTHON_SHA256, and GPG_KEY variables are not set; run python --version instead.
  • OpenSSL. The cryptography package uses the system OpenSSL 3.5, the same library as Python's ssl module. In the upstream image, cryptography bundles its own OpenSSL 4.0.3. In FIPS variants, both use the OpenSSL FIPS provider.
  • Files not included./package (a wheel build directory left in the upstream image) and /src/requirements.txt are not in this image.
  • Platforms. The image is built for linux/amd64 and linux/arm64. The upstream image is also built for linux/ppc64le.
  • Shell and package manager. Runtime and FIPS images include neither. The dev variants run as root and add bash, coreutils, and findutils, with apt on Debian or apk and BusyBox on Alpine.

FIPS variants

The -fips and -fips-dev tags, such as 1.11.1-debian13-fips and 1.11.1-alpine3.24-fips, use OpenSSL 3.5 with the OpenSSL FIPS provider. Python's ssl and hashlib modules and the cryptography package all use it, so non-approved algorithms such as MD5 are refused. The image metadata declares fips-compliant: true and stig-certified: true. To check that FIPS mode is on, run:

docker run --rm --entrypoint /usr/lib/kubeflow-volumes-web-app/venv/bin/python dhi.io/kubeflow-volumes-web-app:<tag> -c "import _hashlib; print(_hashlib.get_fips_mode())"

It prints 1 on FIPS tags and 0 on other tags.

Image variants

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:

    • Run as a nonroot user
    • Do not include a shell or a package manager
    • Contain only the minimal set of libraries needed to run the app
  • 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:

    • Run as the root user
    • Include a shell and package manager
    • Are used to build or compile applications
  • 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.

Migrate to a Docker Hardened Image

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.

ItemMigration note
Base imageReplace your base images in your Dockerfile with a Docker Hardened Image.
Package managementNon-dev images, intended for runtime, don't contain package managers. Use package managers only in images with a dev tag.
Non-root userBy 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 buildUtilize images with a dev tag for build stages and non-dev images for runtime. For binary executables, use a static image for runtime.
TLS certificatesDocker Hardened Images contain standard TLS certificates by default. There is no need to install TLS certificates.
PortsNon-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 pointDocker 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 shellBy 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.

  1. 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.

  2. 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.

  3. 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.

  4. 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.

Troubleshooting migration

The following are common issues that you may encounter during migration.

General debugging

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.

Permissions

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.

Privileged 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, 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.

No shell

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.

Entry point

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.