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.

Example command

  kubectl --context $REMOTE_CONTEXT1 -n bookinfo debug -i pods/$(kubectl get pod --context $REMOTE_CONTEXT1 -l app=reviews -A -o jsonpath='{.items[0].metadata.name}') --image=curlimages/curl -- curl -v http://ratings:9080/ratings/1 -X OPTIONS -H "Origin: http://istio.io" -H "Access-Control-Request-Method: GET"
  

If the output has an error about EphemeralContainers, continue reviewing the information on this page to troubleshoot the issue.

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.

Alternative steps

Instead of using an ephemeral container, you can create a test pod such as curl.

  1. Create the curl pod.
      kubectl run -it -n bookinfo --context $REMOTE_CONTEXT1 curl \
      --image=curlimages/curl:7.73.0 --rm  -- sh
      
  2. Send a request to the ratings app.
      curl http://ratings:9080/ratings/1 -v -X OPTIONS -H "Origin: http://istio.io" -H "Access-Control-Request-Method: GET"
      
  3. Exit the temporary pod. The pod deletes itself.
      exit