官术网_书友最值得收藏!

Pods with more than one container

Our examples have been simple so far, with a single container in a Pod. A Pod can have more than one container at a time, and the command to get the logs can specify which container to use. If there is only one container, you don’t need to specify which one to use.

If you need to specify a specific container, you can do so with either the -c option, or by adding it onto the logs command. For example, if you had a Pod named webapp with two containers, flask and background, and you wanted to see the logs from the background container, you could use the kubectl logs webapp background or kubectl logs webapp -c background commands.

Likewise, there's a shortcut for defining Pods and containers within a deployment. Rather than specifying the full Pod name based on the names assigned through Kubernetes, you can prefix the name of the Pod with just the deployment name. For example, if we had created a deployment with the kubectl run flask image=… command from our earlier examples, we could use the following command:

kubectl logs deployment/flask

This is rather than looking up the specific Pod name and then asking for the logs based on that name.

主站蜘蛛池模板: 织金县| 黄陵县| 四川省| 娄底市| 泾川县| 宣汉县| 平罗县| 隆德县| 镇宁| 东乌| 黑河市| 临夏市| 洛川县| 井冈山市| 华宁县| 青川县| 修武县| 扶余县| 赫章县| 阳朔县| 会理县| 三台县| 新田县| 荆州市| 尼木县| 临朐县| 石景山区| 八宿县| 穆棱市| 景谷| 即墨市| 包头市| 博白县| 马公市| 绥棱县| 犍为县| 抚宁县| 莒南县| 隆昌县| 绥中县| 大冶市|