gpt4 book ai didi

kubernetes - `kubectl logs counter` 在官方 Kubernetes 示例之后没有显示任何输出

转载 作者:行者123 更新时间:2023-12-02 11:37:33 25 4
gpt4 key购买 nike

在部署一个非常简单的 Pod 时,我看不到任何日志输出:

我的配置文件:

apiVersion: v1
kind: Pod
metadata:
name: counter
spec:
containers:
- name: count
image: busybox
args: [/bin/sh, -c,
'i=0; while true; do echo "$i: $(date)"; i=$((i+1)); sleep 1; done']

然后

kubectl apply -f myconfig.yaml

这取自官方教程:https://kubernetes.io/docs/concepts/cluster-administration/logging/#basic-logging-in-kubernetes

pod 似乎运行良好:

kubectl describe pod counter
Name: counter
Namespace: default
Node: ip-10-0-0-43.ec2.internal/10.0.0.43
Start Time: Tue, 20 Nov 2018 12:05:07 -0500
Labels: <none>
Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{},"name":"counter","namespace":"default"},"spec":{"containers":[{"args":["/bin/sh","-c","i=0...
Status: Running
IP: 10.0.0.81
Containers:
count:
Container ID: docker://d2dfdb8644b5a6488d9d324c8c8c2d4637a460693012f35a14cfa135ab628303
Image: busybox
Image ID: docker-pullable://busybox@sha256:2a03a6059f21e150ae84b0973863609494aad70f0a80eaeb64bddd8d92465812
Port: <none>
Host Port: <none>
Args:
/bin/sh
-c
i=0; while true; do echo "$i: $(date)"; i=$((i+1)); sleep 1; done
State: Running
Started: Tue, 20 Nov 2018 12:05:08 -0500
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-r6tr6 (ro)
Conditions:
Type Status
Initialized True
Ready True
PodScheduled True
Volumes:
default-token-r6tr6:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-r6tr6
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 16m default-scheduler Successfully assigned counter to ip-10-0-0-43.ec2.internal
Normal SuccessfulMountVolume 16m kubelet, ip-10-0-0-43.ec2.internal MountVolume.SetUp succeeded for volume "default-token-r6tr6"
Normal Pulling 16m kubelet, ip-10-0-0-43.ec2.internal pulling image "busybox"
Normal Pulled 16m kubelet, ip-10-0-0-43.ec2.internal Successfully pulled image "busybox"
Normal Created 16m kubelet, ip-10-0-0-43.ec2.internal Created container
Normal Started 16m kubelet, ip-10-0-0-43.ec2.internal Started container

运行时没有出现:

kubectl logs counter --follow=true

最佳答案

我唯一能想到的可能导致它不输出日志的是,如果你配置了 default logging driver在您的 /etc/docker/docker.json 中用于 Docker运行 Pod 的节点的配置文件:

{
"log-driver": "anything-but-json-file",
}

这基本上会生成 Docker,而不是为类似 kubectl logs <podid> -c <containerid> 的东西输出 stdout/stderr 日志.您可以查看节点 ( 10.0.0.43 ) 中容器中配置的内容:

$ docker inspect -f '{{.HostConfig.LogConfig.Type}}' <container-id>

关于kubernetes - `kubectl logs counter` 在官方 Kubernetes 示例之后没有显示任何输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53398316/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com