Using Ephemeral Containers

Introduction

Ephemeral container is a special type of container that runs temporarily in an existing Pod to accomplish user-initiated actions such as troubleshooting. It is especially useful when kubectl exec is insufficient because a container has crashed or a container image doesn't include debugging utilities.

For instance, ephemeral containers help you execute a curl request from within pods that typically lack this utility.

Ephemeral containers are turned on by default in Kubernetes v1.23 and later


How to Launch an Ephemeral Container

Wherever you can access pod resources in Devtron, you can launch an ephemeral container as shown below.

From Devtron (App Details)

  1. In the left sidebar, go to Applications.

  2. Search and click your application from the list of Devtron Apps.

  3. Go to the App Details tab.

  4. Under the K8 Resources tab, select Pod inside Workloads.

  5. Locate the pod you wish to debug. Hover and choose click Terminal.

  6. Click Launch Ephemeral Container as shown below.

  7. You get 2 tabs:

    1. Basic - It provides the bare minimum configurations required to launch an ephemeral container.

    It contains 3 mandatory fields:

    • Container name prefix - Type a prefix to give to your ephemeral container, for e.g., debug. Your container name would look like debug-jndvs.

    • Image - Choose an image to run from the dropdown. Ephemeral containers need an image to run and provide the capability to debug, such as curl. You can use a custom image too.

    • Target Container name - Since a pod can have one or more containers, choose a target container you wish to debug, from the dropdown.

    • Advanced - It is particularly useful for advanced users that wish to use labels or annotations since it provides additional key-value options. Refer Ephemeral Container Spec to view the supported options.

Devtron ignores the `command` field while launching an ephemeral container
  1. Click Launch Container.

From Devtron (Resource Browser)

  1. In the left sidebar, go to Resource Browser.

  2. Select Pod inside Workloads.

  3. Use the searchbar to find and locate the pod you wish to debug. Click the pod.

  4. Go to the Terminal tab

The rest is same as steps 6, 7, and 8 mentioned in the previous section.

From Devtron's Cluster Terminal

(This is not a recommended method. This option is available only if you are an admin.)

You can launch an ephemeral container from Kubernetes CLI. For this, you need access to the cluster terminal on Devtron.


Removing an Ephemeral Container

You can remove an ephemeral container using either App Details or Resource Browser (from the same screen you used to create the ephemeral container).

You cannot use App Details or Resource Browser to remove an ephemeral container created using Kubernetes CLI

Last updated