How do I enable Pod Debug in an access cluster?
To use the Pod Debug feature in an access cluster, the following conditions must be met:
-
The Kubernetes version of the cluster is greater than 1.18.
-
The EphemeralContainers feature switch has been enabled for the kube-apiserver, kube-controller-manager, and kube-scheduler components on all control nodes in the cluster.
-
The EphemeralContainers feature switch has been enabled for the kubelet component on all compute nodes in the cluster.
This article will use the Kubernetes Cluster as an example to show you how to enable the EphemeralContainers feature switch for the relevant components on all Controller Nodes and Compute nodes in the cluster.
Turn on the function switch of the component on the control node
To enable the EphemeralContainers feature switch for the corresponding components, modify the kube-apiserver.yaml, kube-controller-manager.yaml, and kube-scheduler.yaml configuration files on all control nodes in the cluster.
Procedure:
-
Run the following command on the control node to enter the directory where the files are located.
cd /etc/kubernetes/manifests/ -
Execute the following command line and modify the container startup parameters in the kube-apiserver.yaml, kube-controller-manager.yaml, and kube-scheduler.yaml files according to the examples.
vi <Configuration file name>Tip:Multiple values are separated by
,. If the corresponding configuration item is missing in the file, please add it manually.example
spec: containers: - command: - <Component name> ## The component name corresponding to the configuration file. kube-apiserver, kube-controller-manager, kube-scheduler - --feature-gates=EphemeralContainers=true,... -
Execute the following command line to restart kubelet.
systemctl restart kubelet.service
Turns on the function switch of the component on the compute node
By modifying the startup parameters of the kubelet component on All Compute Nodes in the cluster, enable the EphemeralContainers function switch.
Option 1
-
Execute the following command on the compute node and add the environment variable
--feature-gates=EphemeralContainers=trueto the kubeadm-flags.env file, referring to the example.vi /var/lib/kubelet/kubeadm-flags.envFor example
KUBELET_KUBEADM_ARGS="--feature-gates=EphemeralContainers=true,CSIStorageCapacity=true --hostname-override=192.168.31.207 --network-plugin=cni --node-ip=192.168.31.207,2002::192:168:31:207 --node-labels=platform.tkestack.io/machine-ipv6-head=2002aa192a,platform.tkestack.io/machine-ipv6-tail=168a31a207 --pod-infra-container-image=192.168.31.206:60080/tkestack/pause:3.2" -
Execute the following command line to restart kubelet.
systemctl restart kubelet.service
Plan 2
-
Execute the following command on the computing node. Refer to the example in the config.yaml file and add the
EphemeralContainers: trueconfiguration item to the featureGates parameter.vi /var/lib/kubelet/config.yamlFor example
featureGates: IPv6DualStack: true EphemeralContainers: true -
Execute the following command line to restart kubelet.
systemctl restart kubelet.service