Ayhan Balik
Ayhan Balik

Reputation: 121

Kubernetes Alpha Debug command

I'm trying the debug CLI feature on 1.18 release of Kubernetes but I have an issue while I have executed debug command.

I have created a pod show as below.

kubectl run ephemeral-demo --image=k8s.gcr.io/pause:3.1 --restart=Never

After than when running this command: kubectl alpha debug -it ephemeral-demo --image=busybox --target=ephemeral-demo

Kubernetes is hanging like that :

Defaulting debug container name to debugger-aaaa.

How Can I resolve that issue?

Upvotes: 5

Views: 762

Answers (3)

VAS
VAS

Reputation: 9031

In addition to the answer posted by Konstl

To enable EphemeralContainers featureGate correctly, add on the master nodes to:

/etc/kubernetes/manifests/kube-apiserver.yaml  
/etc/kubernetes/manifests/kube-controller-manager.yaml  
/etc/kubernetes/manifests/kube-scheduler.yaml

the following line to container command:

spec:
  containers:
  - command:
    - kube-apiserver # or kube-controller-manager/kube-scheduler
    - --feature-gates=EphemeralContainers=true  # < -- add this line

Pods will restart immediately.

For enabling the featureGate for kubelet add on all nodes to:

/var/lib/kubelet/config.yaml

the following lines at the bottom:

featureGates:
  EphemeralContainers: true

Save the file and run the following command:

$ systemctl restart kubelet

This was enough in my case to be able to use kubectl alpha debug as it's explained in the documentation

Additional usefull pages:

Upvotes: 1

Konstl
Konstl

Reputation: 873

It seems that you need to enable the feature gate on all control plane components as well as on the kubelets. If the feature is enabled partially (for instance, only kube-apiserver and kube-scheduler), the resources will be created in the cluster, but no containers will be created, thus there will be nothing to attach to.

Upvotes: 2

niko
niko

Reputation: 151

I'm seeing similar behaviour. Although i'm running 1.17 k8s with 1.18 kubectl. But I was under the impression that the feature was added in 1.16 in k8s and in 1.18 in kubectl.

Upvotes: 0

Related Questions