为什么我无法通过kubectl日志查看k8s klog中的日志



我在k8s:中看到了一些源代码

// delete immediately, or no graceful deletion supported
klog.V(6).Infof("going to delete %s from registry: ", name)
if _, _, err := e.Delete(ctx, accessor.GetName(), deleteValidation, options); err != nil && !apierrors.IsNotFound(err) {
klog.V(4).Infof("Delete %s in DeleteCollection failed: %v", accessor.GetName(), err)
errs <- err
return
}

我想我可以通过kubectl logs检查这些日志,但我看不到它们,即使使用kubectl logs --v 6 <kubeapi server pod> | grep "going to delete"kubectl logs --v 4 <kubeapi server pod> | grep "DeleteCollection",我仍然看不到应该由klog输出的日志。我如何检查这些日志?

答案是:在kube-api服务器配置文件中添加--v=4 arg,以启用日志详细信息。

文件路径:/etc/kubernetes/manifests/kube-apiserver.yaml

apiVersion: v1
kind: Pod
metadata:
annotations:
kubeadm.kubernetes.io/kube-apiserver.advertise-address.endpoint: 192.168.49.2:8443
creationTimestamp: null
labels:
component: kube-apiserver
tier: control-plane
name: kube-apiserver
namespace: kube-system
spec:
containers:
- command:
- kube-apiserver
- --advertise-address=192.168.49.2
- --allow-privileged=true
- --v=4
.......

则kubectl log-v=4

相关内容

  • 没有找到相关文章

最新更新