经过describe命令学习Kubernetes的pod属性详解

咱们能够首先使用kubectl get pods命令获得pod列表,好比咱们想研究pod nginx-storage-pod的明细:html

使用命令kubectl describe pod nginx-storage-pod > nginx-storage-pod.yaml, 将describe命令的输出重定向到一个yaml文件里。用vi打开这个yaml文件:node

pod的全部属性能够从这个yaml文件里学习:nginx

node:shoot--k8s-train--shacw46-worker-prvfv-z1-7844dc6744-ghd5m/10.250.0.6docker

代表pod所在的node,这个node必定是命令kubectl get node返回的结果之一:oop

image

Image:表明该pod是基于哪个docker image建立的。学习

Mount:该pod使用的persistent volume对应的物理文件目录,个人例子是.usr/share/nginx/htmlrest

这个路径从哪里来的呢?就是个人pod文件的yaml文件里的定义:htm

describe命令除了本文介绍的能够用来深刻学习pod的属性外,还能够用于pod不能正常启动时的错误排查。blog

好比我有一个pod名为another3,状态一直处于CrashLoopBackOff, RESTART次数为12:get

使用kubectl describe pod another3就能够看到这个容器启动的明细:Back-off restarting failed container

仔细检查pod的yaml文件,发现缘由是由于我定义了volume的name为content-storage,可是没有指定persistentvolumeclaim。当我把volumes: - name: content-storage删除以后,

下图是修改后的yaml文件:

从新建立名为another3的pod,很快就建立成功而且状态处于running了:

要获取更多Jerry的原创文章,请关注公众号"汪子熙":

相关文章
相关标签/搜索