本文介绍了从副本集中的特定容器获取所有日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从副本集中运行的特定容器中获取所有日志
How can I get all the logs from a specific container(s) that are running in a replica set
我试过了,但是没用
kubectl logs -l=app={app-name},name={container-name} -n={namespace}
推荐答案
您需要使用 -c标志指定容器名称
You need to use -c flag to specify the Container name
kubectl日志-l = app = {app-name} -c = {container-name} -n = {namespace}
如您所见, kubectl logs -h
命令的选项
Options:
--all-containers=false: Get all containers's logs in the pod(s).
-c, --container='': Print the logs of this container
-f, --follow=false: Specify if the logs should be streamed.
--limit-bytes=0: Maximum bytes of logs to return. Defaults to no limit.
--pod-running-timeout=20s: The length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one
pod is running
-p, --previous=false: If true, print the logs for the previous instance of the container in a pod if it exists.
-l, --selector='': Selector (label query) to filter on.
--since=0s: Only return logs newer than a relative duration like 5s, 2m, or 3h. Defaults to all logs. Only one of
since-time / since may be used.
--since-time='': Only return logs after a specific date (RFC3339). Defaults to all logs. Only one of since-time /
since may be used.
--tail=-1: Lines of recent log file to display. Defaults to -1 with no selector, showing all log lines otherwise
10, if a selector is provided.
--timestamps=false: Include timestamps on each line in the log output
这篇关于从副本集中的特定容器获取所有日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!