dhi.io/kubeflow-pipelines-viewer-crd-controller
Kubernetes controller that runs TensorBoard viewers for Kubeflow Pipelines Viewer resources.
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/kubeflow-pipelines-viewer-crd-controller:<tag><your-namespace>/dhi-kubeflow-pipelines-viewer-crd-controller:<tag>For the examples, you must first use docker login dhi.io to authenticate to the registry to pull the images.
| Variant | 2.18 on Debian 13 | 2.18 on Alpine 3.24 | 2.17 on Debian 13 | 2.17 on Alpine 3.24 |
|---|---|---|---|---|
| Runtime | 2, 2.18, 2.18.0 | 2-alpine3.24, 2.18-alpine3.24, 2.18.0-alpine3.24 | 2.17, 2.17.3 | 2.17-alpine3.24, 2.17.3-alpine3.24 |
| Dev | 2-dev, 2.18-dev | 2.18-alpine3.24-dev | 2.17-dev | 2.17-alpine3.24-dev |
| FIPS | 2-fips, 2.18-fips | 2.18-alpine3.24-fips | 2.17-fips | 2.17-alpine3.24-fips |
| FIPS dev | 2.18-fips-dev | 2.18-alpine3.24-fips-dev | 2.17-fips-dev | 2.17-alpine3.24-fips-dev |
The 2.18 tags track upstream Kubeflow Pipelines 2.18.x releases, and the 2.17 tags track 2.17.x releases. The bare
2 tags follow the 2.18 line; the 2.17 line has no bare major tag.
This image is the Kubeflow Pipelines Viewer CRD controller from
backend/src/crd/controller/viewer
in the Kubeflow Pipelines project. It watches Viewer resources (kubeflow.org/v1beta1) and, for each one, creates a
TensorBoard Deployment named <viewer>-deployment and a Service named <viewer>-service (port 80 to TensorBoard's port
6006), both owned by the Viewer. When a namespace holds more viewers than MAX_NUM_VIEWERS, it deletes the oldest. It
runs inside a Kubernetes cluster; see the
Kubeflow Pipelines documentation for the rest of the platform.
The image has no entrypoint. Its default command is the same shell-form command as upstream:
/bin/sh -c /bin/controller -logtostderr=true -max_num_viewers=${MAX_NUM_VIEWERS} --namespace=${NAMESPACE}
List the flags the controller accepts:
docker run --rm --entrypoint /bin/controller dhi.io/kubeflow-pipelines-viewer-crd-controller:2.18.0 -h
The controller needs a Kubernetes API server. Started without one, it exits with code 1 and logs
Failed to build valid config from supplied flags:
docker run --rm dhi.io/kubeflow-pipelines-viewer-crd-controller:2.18.0
In a cluster, the controller uses its service account's in-cluster configuration. Outside a cluster, pass -kubecfg (a
kubeconfig path) or -master_url. The other flags you may need are -client_qps (default 5), -client_burst
(default 10), and the glog flags such as -v. The controller has no version flag.
The default command passes these variables to the controller as flags:
| Variable | Description | Default | Required |
|---|---|---|---|
MAX_NUM_VIEWERS | Maximum number of viewers in each namespace before the controller deletes the oldest. Passed as -max_num_viewers. | 50 | No |
NAMESPACE | Namespace whose viewers the controller watches. Set it to an empty string to watch all namespaces. Passed as --namespace. | kubeflow | No |
If you replace the command, the variables no longer apply. Pass the flags yourself, for example
/bin/controller -logtostderr=true -max_num_viewers=20 --namespace=team-a.
Upstream installs the controller only through the kustomize manifests in
manifests/kustomize. To run the DHI image,
keep the upstream manifests, override the image with a kustomize images: entry, and patch the Deployment to run as the
image's user. If you already install Kubeflow Pipelines with these manifests, add the images: entry and the Deployment
patch to your kustomization.
The following kustomization.yaml installs the controller on its own in the kubeflow namespace, from the upstream
service account, Role, RoleBinding, and Deployment at the 2.18.0 tag. The first patch gives the service account a pull
secret for dhi.io. The second replaces the upstream Deployment's runAsUser: 1000 and runAsGroup: 0 with the
image's nonroot user and group, 65532:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: kubeflow
resources:
- https://raw.githubusercontent.com/kubeflow/pipelines/2.18.0/manifests/kustomize/base/pipeline/ml-pipeline-viewer-crd-sa.yaml
- https://raw.githubusercontent.com/kubeflow/pipelines/2.18.0/manifests/kustomize/base/pipeline/ml-pipeline-viewer-crd-role.yaml
- https://raw.githubusercontent.com/kubeflow/pipelines/2.18.0/manifests/kustomize/base/pipeline/ml-pipeline-viewer-crd-rolebinding.yaml
- https://raw.githubusercontent.com/kubeflow/pipelines/2.18.0/manifests/kustomize/base/pipeline/ml-pipeline-viewer-crd-deployment.yaml
images:
- name: ghcr.io/kubeflow/kfp-viewer-crd-controller
newName: dhi.io/kubeflow-pipelines-viewer-crd-controller
newTag: 2.18.0
patches:
- target:
kind: ServiceAccount
name: ml-pipeline-viewer-crd-service-account
patch: |-
- op: add
path: /imagePullSecrets
value:
- name: dhi-pull-secret
- target:
kind: Deployment
name: ml-pipeline-viewer-crd
patch: |-
- op: replace
path: /spec/template/spec/containers/0/securityContext/runAsUser
value: 65532
- op: replace
path: /spec/template/spec/containers/0/securityContext/runAsGroup
value: 65532
Create the namespace, the Viewer CustomResourceDefinition, and the pull secret, then apply the kustomization from the
directory that contains it:
kubectl create namespace kubeflow
kubectl apply -f https://raw.githubusercontent.com/kubeflow/pipelines/2.18.0/manifests/kustomize/base/pipeline/cluster-scoped/viewer-crd.yaml
kubectl -n kubeflow create secret docker-registry dhi-pull-secret \
--docker-server=dhi.io \
--docker-username=<your-docker-id> \
--docker-password=<your-access-token>
kubectl apply -k .
kubectl -n kubeflow rollout status deployment/ml-pipeline-viewer-crd
The controller logs Starting controller for the Viewer CRD when it is running. The upstream Deployment adds no command
or arguments, so the image's default command runs. It sets MAX_NUM_VIEWERS to 50 and sets NAMESPACE to the pod's
own namespace. With the patch, the pod runs as 65532:65532, the same user as docker run, and keeps the rest of the
upstream security context: runAsNonRoot, no privilege escalation, all capabilities dropped, and the RuntimeDefault
seccomp profile.
Upstream's multi-user install,
installs/multi-user/viewer-controller,
sets NAMESPACE to an empty string so that the controller watches every namespace, and binds a ClusterRole instead of
the Role. The same images: entry and Deployment patch apply to it.
This viewer.yaml is based on the upstream sample. It must be in the namespace the controller watches:
apiVersion: kubeflow.org/v1beta1
kind: Viewer
metadata:
name: mnist-viewer
namespace: kubeflow
spec:
type: tensorboard
tensorboardSpec:
logDir: gs://ml-pipeline-playground/mnist/
Apply it and check the objects the controller creates:
kubectl apply -f viewer.yaml
kubectl -n kubeflow get deployment/mnist-viewer-deployment service/mnist-viewer-service
The TensorBoard image comes from spec.tensorboardSpec.tensorflowImage. When you leave it empty, each line uses
upstream's default for that release:
| Controller tags | Default TensorBoard image |
|---|---|
2.18, 2 | ghcr.io/kubeflow/kfp-tensorboard:2.18.0 |
2.17 | tensorflow/tensorflow:1.13.2 |
The controller adds --bind_all to the TensorBoard arguments unless the image tag starts with 1..
The controller creates the Deployment and Service only when they are missing, and never updates them. To change a
viewer, delete it and create it again. When you delete a Viewer, Kubernetes garbage collection removes its Deployment
and Service.
The controller serves Prometheus metrics on port 8080 at /metrics. To check them from your workstation, forward the
port:
kubectl -n kubeflow port-forward deployment/ml-pipeline-viewer-crd 8080:8080
Then, in a second terminal, request the metrics:
curl http://localhost:8080/metrics
The default command, working directory (/bin), environment variables, and /bin/controller path match the upstream
image. These differences affect how you run it:
1000:0; the kustomization in this guide patches that to the image's 65532:65532. The runtime and FIPS
images run as UID 65532 (nonroot)./bin/sh, provided by
busybox, because the default command is shell-form, as upstream's is. That shell is how the upstream manifests pass
MAX_NUM_VIEWERS and NAMESPACE to the controller. Busybox replaces itself with the controller, which runs as PID 1
and receives SIGTERM directly. The Alpine images include the busybox applets, such as ls. The Debian images
include only sh. Neither has a package manager.-dev images run as root and add a package manager (apk on Alpine, apt on Debian), bash,
coreutils, and findutils. Use them to inspect or debug the image, and deploy a runtime tag.-fips images contain the controller built with the Go FIPS 140-3 cryptographic module, with
FIPS mode on by default, so its TLS connections to the Kubernetes API use that module. They also include the OpenSSL
FIPS provider.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.