Skip to main content
With Imageless Kubernetes, you can run a container just like in any other Kubernetes deployment, but you don’t have to build a container image. To demonstrate this, we’ll run a simple web server backed by Redis using two Flox environments.

Prerequisites

Before you start, make sure you have: The example pulls its Flox environments from FloxHub, so the shim needs a FloxHub token. just up copies your token into a Kubernetes secret for you and stops with an error if you are not logged in. See Configuration for how that secret is created and mounted.

Running the example

The entirety of this example can be run locally with the following commands:
This starts a local Kubernetes cluster using kind and deploys a web server backed by Redis. To fetch something from the web server, run:

Quotes app environment

The example runs a deployment of flox/quotes-app, which is just like any other Kubernetes deployment, but with a few key differences. Here’s a snippet from the deployment manifest:
The full deployment manifest can be found in the flox-kind-demo repo. There are two key lines needed to run the container using a Flox environment instead of a container image:
  • Specifying runtimeClassName: flox runs the container using the Flox containerd shim.
  • The annotation flox.dev/environment: "flox/quotes-app" specifies the Flox environment to use to bootstrap the container filesystem instead of a container image
Just as with any container, you can specify a startup command, which is ["quotes-app-go", "-r", "redis:6379"] in this case. When the container starts, the flox/quotes-app Flox environment is pulled from FloxHub and bind mounted into the container. This environment contains the flox/quotes-app-go package, which is a simple web server published to FloxHub. When the container starts, the environment is activated, and then quotes-app-go is run inside the activated environment.

Redis environment

The quotes-app-go server uses a Redis instance running in a second deployment. Just like the first pod, rather than specifying a container image, the Redis deployment runs the environment flox/redis which is pulled from hub.flox.dev/flox/redis. Here’s the relevant snippet from the Redis deployment manifest:
The full deployment manifest can be found in the flox-kind-demo repo.

Updating the deployment

Because the environment is hosted on FloxHub, there’s no need to rebuild a container image to update the deployment. After a change to quotes-app-go, updating the deployment would require running a flox publish for quotes-app-go and a flox upgrade -r flox/quotes-app. After that, restarting a pod will pull the latest generation of the environment. This allows deploying software with the reproducibility of a container, but without the overhead of having to rebuild an entire container image when iterating.

Cleaning up

To tear down the local kind cluster, run: