Field Note

Creating dev containers with `odo` and Devfile on a local Kubernetes cluster

devcontainer kubernetes local odo
Posted on Monday, April the 22nd 2024
1 min read

Devfile is standard for declaring containerized development environments. We may use Devfiles in combination with odo to set up and tear down dev environments on Kubernetes.

To create a dev environment on a local Kubernetes cluster with Devfile and odo, only three steps are necessary:

  1. Start the local Kubernetes cluster E.g. the integrated Kubernetes cluster of Rancher Desktop.
  2. Install the odo CLI E.g. on macOS with Brew, run
    brew update && brew install odo-dev
    
  3. Create a Devfile
    mkdir -p /tmp/devfile
    cd /tmp/devfile
    cat <<EOF > .devfile.yaml
    schemaVersion: 2.1.0
    components:
    - name: thedevcontainer
      container:
        image: ubuntu:22.04
        command: ['sleep', 'infinity']
        mountSources: true
    EOF
    odo dev
    

The above should start a pod running Ubuntu 22.04 in the local Kubernetes cluster and we may exec into it and run commands.

friedrichkurz.me

© 2025 Friedrich Kurz

Privacy Policy