DevZero Logo
DevZero

Workspace Cluster

Deploying and managing applications in workspace Kubernetes clusters.

DevZero’s workspace clusters are designed to provide a developer-friendly Kubernetes experience without requiring extensive infrastructure management. Each workspace is provisioned with its own ephemeral, namespaced Kubernetes cluster, enabling developers to deploy and test their applications in an isolated environment quickly and easily.

This page focuses on helping developers deploy applications and interact with Kubernetes clusters provisioned for workspaces Whether you’re testing, deploying microservices, or running containerized workloads, this guide will walk you through the process.

To watch a video tutorial, click here for a 5-minute walkthrough!

Using Kubernetes Clusters in a Workspace

To start using Kubernetes clusters in a workspace, you’ll first need to retrieve the kubeconfig and update your Kubernetes configuration file.

To view the Kubernetes configuration for a workspace, run:

For example, if you have a workspace named "big-skylark-sezs"
dz workspace kubeconfig big-skylark-sezs 

To write the config to the default Kubernetes configuration location, run:

For example, if you have a workspace named "big-skylark-sezs"
dz workspace kubeconfig big-skylark-sezs --update-kubeconfig

Then run commands like:

kubectl get pods

From Inside a DevBox

When inside a DevBox context (i.e. when connected to a workspace), the CLI is able to retrieve environmental information from /etc/devzero.

In a fresh new workspace, you can immediately run:

kubectl get pods

DevZero reserves the default namespace for its managed deployments. Do not operate on this namespace. Adding or removing resources in this namespace will lead to undocumented behaviors and potential data loss.

dz workspace kubeconfig -h
This kubeconfig can be used by any kubectl to interact with the virtual cluster backing a workspace.
Usage: kubectl --kubeconfig <(dz ws kubeconfig <workspace_id | workspace_name>) ...

Usage:
  dz workspace kubeconfig <workspace_id | workspace_name> [flags]

Aliases:
  kubeconfig, kc

Flags:
  -h, --help                help for kubeconfig
  -u, --update-kubeconfig   update local kubeconfig (default: $HOME/.kube/config)

Global Flags:
      --verbose   Get detailed output

Deploying Applications to Workspace Clusters

This section provides a practical guide to deploying applications to your Kubernetes cluster.

Tutorial Video

Here’s a video covering how you can access and deploy apps to your workspace's Kubernetes cluster:

Step-by-Step Guide

Follow these steps to replicate what’s shown in the video and deploy your applications:

  1. Create a Recipe: Go to devzero.io/dashboard/recipes/new.

    • Give it a name, leave everything else blank, and click Create a recipe.
    • Once the recipe is created, you’ll see the recipe editor screen.

    Recipe with no repo

  2. Use the Following Recipe: Copy and paste the YAML below into the recipe editor, then click Save and Build. Once the build completes successfully, click Launch.

version: "3"
build:
  steps:
    - type: apt-get
      packages:
        [
          "apt-transport-https",
          "build-essential",
          "ca-certificates",
          "curl",
          "git",
          "nano",
          "software-properties-common",
          "ssh",
          "sudo",
          "tar",
          "unzip",
          "vim",
          "wget",
          "zip",
        ]
    - type: git-clone
      url: https://github.com/GoogleCloudPlatform/microservices-demo
    - type: command
      command: |
        curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
        sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl && rm kubectl
    - type: command
      command: |
        curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 && \
        sudo install skaffold /usr/local/bin/
    - type: apt-get
      packages: ["docker-ce", "docker-ce-cli", "containerd.io"]
      extra_repositories:
        - key_url: https://download.docker.com/linux/ubuntu/gpg
          repository: https://download.docker.com/linux/ubuntu
          components: []
          distribution: ""
    - type: command
      command: |
        usermod -aG docker devzero
        systemctl enable docker.service
        systemctl enable containerd.service
      user: root
  1. Build a workspace from the recipe, and run the following in your terminal:
dz workspace connect <workspace_name>
  1. Run the following steps inside the SSH session that's connected to your workspace:
kubectl get pods  # verification
cd /home/devzero/microservices-demo
skaffold run --default-repo ttl.sh  # this will take a bit of time since its building multiple docker images (~5mins)
  1. Verify that all the pods are running:
kubectl get pods
  1. Port Forward the frontend Service: Use the following command to forward the frontend service’s port to your terminal session:
kubectl port-forward --address 0.0.0.0 deployment/frontend 8088:8080
  1. Visit https://<workspace_name>:8088 where <workspace_name> is the name of your workspace to see the app!

On this page