Ephemeral containers

As part of testing Gloo and Istio service mesh features, you might try to use ephemeral containers. For example, ephemeral containers can let you run a curl request from inside pods that do not normally have this utility.

What's happening

To test connectivity between Bookinfo pods, you might use the kubectl debug CLI command. This command can use ephemeral containers to add helpful testing tools like curl.

However, when you run the kubectl debug command, you might see errors similar to the following.

error: ephemeral containers are disabled for this cluster (error from server: "the server could not find the requested resource").
error: error updating ephemeral containers: EphemeralContainers in version "v1" cannot be handled as a Pod: no kind "EphemeralContainers" is registered for version "v1" in scheme "k8s.io/kubernetes/pkg/api/legacyscheme/scheme.go:30"

Why it's happening

These errors indicate that your Kubernetes version does not support ephemeral containers. Ephemeral containers are an alpha feature in Kubernetes 1.22 or earlier, and might not be enabled by default.

How to fix it

  1. Check the Kubernetes version of your CLI client and cluster server.
    kubectl version --context ${REMOTE_CONTEXT1}
  2. If your cluster server version is 1.22 or earlier, review the following options.
    1. Update the Kubernetes feature gates in your cluster to allow ephemeral containers.
    2. Upgrade your cluster to Kubernetes 1.23 or later. Consult your infrastructure provider for instructions.
  3. If your CLI client version is 1.22 or earlier, upgrade the kubectl CLI.