双美 發表於 2020-3-18 11:46:00

031.Kubernetes核心组件-kubelet

<h2 align="left">一        kubelet概述</h2><font face="微软雅黑" size="2">
</font><h3 align="left">1.1        kubelet作用</h3><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; text-indent: 28px; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">在Kubernetes集群中,在每个Node(又称Minion)上都会启动一个kubelet服务进程。该进程用于处理Master下发到本节点的任务,管理Pod及Pod中的容器。每个kubelet进程都会在API Server上注册节点自身的信息,定期向Master汇报节点资源的使用情况,并通过cAdvisor监控容器和节点资源。</font></div><font face="微软雅黑" size="2">
</font><h2 align="left">二        节点管理</h2><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; text-indent: 28px; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">节点通过设置kubelet的启动参数“--register-node”,来决定是否向API Server注册自己。如果该参数的值为true,那么kubelet将试着通过API Server注册自己。在自注册时,kubelet启动时还包含下列参数。</font></div><font face="微软雅黑" size="2">
</font><div style="line-height: normal; -ms-word-break: normal"><font face="微软雅黑" size="2">
</font><ul style="margin: 0; padding-left: 30pt" yne-block-type="list"><font face="微软雅黑" size="2">
</font><li style="text-align: left; line-height: 1.75; list-style-type: disc; list-style-position: inside; white-space: pre-wrap; background-color: rgba(0, 0, 0, 0)"><font face="微软雅黑" size="2">--api-servers:API Server的位置。</font></li><font face="微软雅黑" size="2">
</font><li style="text-align: left; line-height: 1.75; list-style-type: disc; list-style-position: inside; white-space: pre-wrap; background-color: rgba(0, 0, 0, 0)"><font face="微软雅黑" size="2">--kubeconfig:kubeconfig文件,用于访问API Server的安全配置文件。</font></li><font face="微软雅黑" size="2">
</font><li style="text-align: left; line-height: 1.75; list-style-type: disc; list-style-position: inside; white-space: pre-wrap; background-color: rgba(0, 0, 0, 0)"><font face="微软雅黑" size="2">--cloud-provider:云服务商(IaaS)地址,仅用于公有云环境。</font></li></ul></div><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font color="#ff0000" face="微软雅黑" size="2"><strong>提示:通常可能每个kubelet都被授予创建和修改任何节点的权限。生产环境中,建议kubelet的权限进行限制,仅允许它修改和创建所在节点的权限。</strong></font></div><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; text-indent: 28px; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">如果在集群运行过程中遇到集群资源不足的情况,用户就很容易通过添加机器及运用kubelet的自注册模式来实现扩容。</font></div><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; text-indent: 28px; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">在某些情况下,Kubernetes集群中的某些kubelet没有选择自注册模式,用户需要自己去配置Node的资源信息,同时告知Node上Kubelet API Server的位置,需要手动创建和修改节点信息。</font></div><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; text-indent: 28px; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">如果需要手动创建节点信息,则通过设置kubelet的启动参数“--registernode=false”即可关闭自注册模式。</font></div><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; text-indent: 28px; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">kubelet在启动时通过API Server注册节点信息,并定时向API Server发送节点的新消息,API Server在接收到这些信息后,将这些信息写入etcd。通过kubelet的启动参数“--node-status-update-frequency”设置kubelet每隔多长时间向API Server报告节点状态,默认为10s。</font></div><font face="微软雅黑" size="2">
</font><h2 align="left">三        Pod管理</h2><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; text-indent: 28px; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">kubelet通过以下几种方式获取自身Node上要运行的Pod清单。</font></div><font face="微软雅黑" size="2">
</font><div style="line-height: normal; -ms-word-break: normal"><font face="微软雅黑" size="2">
</font><ol style="margin: 0; padding-left: 30pt" yne-block-type="list"><font face="微软雅黑" size="2">
</font><li style="text-align: left; line-height: 1.75; list-style-type: decimal; list-style-position: inside; white-space: pre-wrap; background-color: rgba(0, 0, 0, 0)"><font face="微软雅黑" size="2">文件:kubelet启动参数“--config”指定的配置文件目录下的文件(默认目录为“/etc/kubernetes/manifests/”)。通过--file-checkfrequency设置检查该文件目录的时间间隔,默认为20s。</font></li><font face="微软雅黑" size="2">
</font><li style="text-align: left; line-height: 1.75; list-style-type: decimal; list-style-position: inside; white-space: pre-wrap; background-color: rgba(0, 0, 0, 0)"><font face="微软雅黑" size="2">HTTP端点(URL):通过“--manifest-url”参数设置。通过--http-check-frequency设置检查该HTTP端点数据的时间间隔,默认为20s。</font></li><font face="微软雅黑" size="2">
</font><li style="text-align: left; line-height: 1.75; list-style-type: decimal; list-style-position: inside; white-space: pre-wrap; background-color: rgba(0, 0, 0, 0)"><font face="微软雅黑" size="2">API Server:kubelet通过API Server监听etcd目录,同步Pod列表。</font></li></ol></div><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><br></div><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; text-indent: 28px; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">所有以非API Server方式创建的Pod都叫作Static Pod。kubelet将Static Pod的状态汇报给API Server,API Server为该Static Pod创建一个Mirror Pod和其相匹配。Mirror Pod的状态将真实反映Static Pod的状态。当Static Pod被删除时,与之相对应的Mirror Pod也会被删除。</font></div><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; text-indent: 28px; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">对于通过API Server获得Pod清单的方式,kubelet会使用API Server Client的Watch加List的方式监听“/registry/nodes/$”当前节点的名称和“/registry/pods”目录,将获取的信息同步到本地缓存中。</font></div><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; text-indent: 28px; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">kubelet监听etcd,所有针对Pod的操作都会被kubelet监听。如果发现有新的绑定到本节点的Pod,则按照Pod清单的要求创建该Pod。如果发现本地的Pod被修改,则kubelet会做出相应的修改,比如在删除Pod中的某个容器时,会通过Docker Client删除该容器。</font></div><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; text-indent: 28px; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">如果发现删除本节点的Pod,则删除相应的Pod,并通过Docker Client删除Pod中的容器。</font></div><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; text-indent: 28px; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">kubelet读取所监听的信息,如果是创建和修改Pod任务,则做如下处理:</font></div><font face="微软雅黑" size="2">
</font><div style="line-height: normal; -ms-word-break: normal"><font face="微软雅黑" size="2">
</font><ol style="margin: 0; padding-left: 30pt" yne-block-type="list"><font face="微软雅黑" size="2">
</font><li style="text-align: left; line-height: 1.75; list-style-type: decimal; list-style-position: inside; white-space: pre-wrap; background-color: rgba(0, 0, 0, 0)"><font face="微软雅黑" size="2">为该Pod创建一个数据目录。</font></li><font face="微软雅黑" size="2">
</font><li style="text-align: left; line-height: 1.75; list-style-type: decimal; list-style-position: inside; white-space: pre-wrap; background-color: rgba(0, 0, 0, 0)"><font face="微软雅黑" size="2">从API Server读取该Pod清单。</font></li><font face="微软雅黑" size="2">
</font><li style="text-align: left; line-height: 1.75; list-style-type: decimal; list-style-position: inside; white-space: pre-wrap; background-color: rgba(0, 0, 0, 0)"><font face="微软雅黑" size="2">为该Pod挂载外部卷(ExternalVolume)。</font></li><font face="微软雅黑" size="2">
</font><li style="text-align: left; line-height: 1.75; list-style-type: decimal; list-style-position: inside; white-space: pre-wrap; background-color: rgba(0, 0, 0, 0)"><font face="微软雅黑" size="2">下载Pod用到的Secret。</font></li><font face="微软雅黑" size="2">
</font><li style="text-align: left; line-height: 1.75; list-style-type: decimal; list-style-position: inside; white-space: pre-wrap; background-color: rgba(0, 0, 0, 0)"><font face="微软雅黑" size="2">检查已经运行在节点上的Pod,如果该Pod没有容器或Pause容器(“kubernetes/pause”镜像创建的容器)没有启动,则先停止Pod里所有容器的进程。如果在Pod中有需要删除的容器,则删除这些容器。</font></li><font face="微软雅黑" size="2">
</font><li style="text-align: left; line-height: 1.75; list-style-type: decimal; list-style-position: inside; white-space: pre-wrap; background-color: rgba(0, 0, 0, 0)"><font face="微软雅黑" size="2">用“kubernetes/pause”镜像为每个Pod都创建一个容器。该Pause容器用于接管Pod中所有其他容器的网络。每创建一个新的Pod,kubelet都会先创建一个Pause容器,然后创建其他容器。“kubernetes/pause”镜像大概有200KB,是个非常小的容器镜像。</font></li><font face="微软雅黑" size="2">
</font><li style="text-align: left; line-height: 1.75; list-style-type: decimal; list-style-position: inside; white-space: pre-wrap; background-color: rgba(0, 0, 0, 0)"><font face="微软雅黑" size="2">为Pod中的每个容器做如下处理:</font></li></ol></div><font face="微软雅黑" size="2">
</font><div style="line-height: normal; -ms-word-break: normal"><font face="微软雅黑" size="2">
</font><ul style="margin: 0; padding-left: 30pt" yne-block-type="list"><font face="微软雅黑" size="2">
</font><ul style="margin: 0; padding-left: 30pt" yne-block-type="list"><font face="微软雅黑" size="2">
</font><li style="text-align: left; line-height: 1.75; list-style-type: circle; list-style-position: inside; white-space: pre-wrap; background-color: rgba(0, 0, 0, 0)"><font face="微软雅黑" size="2">为容器计算一个Hash值,然后用容器的名称去查询对应Docker容器的Hash值。若查找到容器,且二者的Hash值不同,则停止Docker中容器的进程,并停止与之关联的Pause容器的进程;若二者相同,则不做任何处理。</font></li><font face="微软雅黑" size="2">
</font><li style="text-align: left; line-height: 1.75; list-style-type: circle; list-style-position: inside; white-space: pre-wrap; background-color: rgba(0, 0, 0, 0)"><font face="微软雅黑" size="2">如果容器被终止了,且容器没有指定的restartPolicy(重启策略),则不做任何处理。</font></li><font face="微软雅黑" size="2">
</font><li style="text-align: left; line-height: 1.75; list-style-type: circle; list-style-position: inside; white-space: pre-wrap; background-color: rgba(0, 0, 0, 0)"><font face="微软雅黑" size="2">调用Docker Client下载容器镜像,调用Docker Client运行容器。</font></li></ul></ul></div><font face="微软雅黑" size="2">
</font><h2 align="left">四        容器健康检查</h2><font face="微软雅黑" size="2">
</font><h3 align="left">4.1        健康检查方法</h3><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; text-indent: 28px; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">Pod通过两类探针来检查容器的健康状态,LivenessProbe探针和ReadinessProbe探针。</font></div><font face="微软雅黑" size="2">
</font><h3 align="left">4.2        LivenessProbe探针</h3><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; text-indent: 28px; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">LivenessProbe探针,用于判断容器是否健康并反馈给kubelet。如果LivenessProbe探针探测到容器不健康,则kubelet将删除该容器,并根据容器的重启策略做相应的处理。如果一个容器不包含LivenessProbe探针,那么kubelet认为该容器的LivenessProbe探针返回的值永远是Success。</font></div><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; text-indent: 28px; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">kubelet定期调用容器中的LivenessProbe探针来诊断容器的健康状况。LivenessProbe包含以下3种实现方式:</font></div><font face="微软雅黑" size="2">
</font><div style="line-height: normal; -ms-word-break: normal"><font face="微软雅黑" size="2">
</font><ol style="margin: 0; padding-left: 30pt" yne-block-type="list"><font face="微软雅黑" size="2">
</font><li style="text-align: left; line-height: 1.75; list-style-type: decimal; list-style-position: inside; white-space: pre-wrap; background-color: rgba(0, 0, 0, 0)"><font face="微软雅黑" size="2">ExecAction:在容器内部执行一个命令,如果该命令的退出状态码为0,则表明容器健康。</font></li><font face="微软雅黑" size="2">
</font><li style="text-align: left; line-height: 1.75; list-style-type: decimal; list-style-position: inside; white-space: pre-wrap; background-color: rgba(0, 0, 0, 0)"><font face="微软雅黑" size="2">TCPSocketAction:通过容器的IP地址和端口号执行TCP检查,如果端口能被访问,则表明容器健康。</font></li><font face="微软雅黑" size="2">
</font><li style="text-align: left; line-height: 1.75; list-style-type: decimal; list-style-position: inside; white-space: pre-wrap; background-color: rgba(0, 0, 0, 0)"><font face="微软雅黑" size="2">HTTPGetAction:通过容器的IP地址和端口号及路径调用HTTPGet方法,如果响应的状态码大于等于200且小于等于400,则认为容器状态健康。</font></li></ol></div><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><br></div><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; text-indent: 28px; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">LivenessProbe探针被包含在Pod定义的spec.containers.{某个容器}中。</font></div><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">示例1:HTTP检查方式</font></div><font face="微软雅黑" size="2">
</font><div id="4734-1574840094447" style="line-height: normal; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="code" data-language="javascript" data-theme="coy"><font face="微软雅黑" size="2"># vi myweb-liveness.yaml
<div class="cnblogs_code"><pre><span style="color: rgba(0, 128, 128, 1)">1</span> apiVersion: v1
<span style="color: rgba(0, 128, 128, 1)">2</span> kind: Pod
<span style="color: rgba(0, 128, 128, 1)">3</span> metadata:
<span style="color: rgba(0, 128, 128, 1)">4</span>   labels:
<span style="color: rgba(0, 128, 128, 1)">5</span>   test: liveness
<span style="color: rgba(0, 128, 128, 1)">6</span>   <span style="color: rgba(0, 0, 255, 1)">name</span>: myweb
<span style="color: rgba(0, 128, 128, 1)">7</span> spec:
<span style="color: rgba(0, 128, 128, 1)">8</span>   containers:
<span style="color: rgba(0, 128, 128, 1)">9</span>   - <span style="color: rgba(0, 0, 255, 1)">name</span>: myweb
<span style="color: rgba(0, 128, 128, 1)"> 10</span>   image: kubeguide/tomcat-app:v1
<span style="color: rgba(0, 128, 128, 1)"> 11</span>   ports:
<span style="color: rgba(0, 128, 128, 1)"> 12</span>   - containerPort: 8080
<span style="color: rgba(0, 128, 128, 1)"> 13</span>   livenessProbe:
<span style="color: rgba(0, 128, 128, 1)"> 14</span>       httpGet:
<span style="color: rgba(0, 128, 128, 1)"> 15</span>         <span style="color: rgba(0, 0, 255, 1)">path</span>: /<span style="color: rgba(0, 0, 255, 1)">index</span>.html
<span style="color: rgba(0, 128, 128, 1)"> 16</span>         port: 8080
<span style="color: rgba(0, 128, 128, 1)"> 17</span>         httpHeaders:
<span style="color: rgba(0, 128, 128, 1)"> 18</span>         - <span style="color: rgba(0, 0, 255, 1)">name</span>: X-Custom-Header
<span style="color: rgba(0, 128, 128, 1)"> 19</span>         value: Awesome
<span style="color: rgba(0, 128, 128, 1)"> 20</span>       initialDelaySeconds: 5
<span style="color: rgba(0, 128, 128, 1)"> 21</span>       timeoutSeconds: 1
<span style="color: rgba(0, 128, 128, 1)"> 22</span> <span style="color: rgba(0, 128, 0, 1)">#kubelet发送一个HTTP请求到本地主机、端口及指定的路径,来检查容器的健康状态。</span></pre></div><font face="微软雅黑" size="2">示例2:运行一个具体的命令。</font></font></div><font face="微软雅黑" size="2">
</font><div id="1526-1574840236833" style="line-height: normal; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="code" data-language="javascript" data-theme="coy"><font face="微软雅黑" size="2"># vi myweb-liveness.yaml
<div class="cnblogs_code"><pre><span style="color: rgba(0, 128, 128, 1)">1</span> apiVersion: v1
<span style="color: rgba(0, 128, 128, 1)">2</span> kind: Pod
<span style="color: rgba(0, 128, 128, 1)">3</span> metadata:
<span style="color: rgba(0, 128, 128, 1)">4</span>   labels:
<span style="color: rgba(0, 128, 128, 1)">5</span>   test: liveness
<span style="color: rgba(0, 128, 128, 1)">6</span>   <span style="color: rgba(0, 0, 255, 1)">name</span>: myweb
<span style="color: rgba(0, 128, 128, 1)">7</span> spec:
<span style="color: rgba(0, 128, 128, 1)">8</span>   containers:
<span style="color: rgba(0, 128, 128, 1)">9</span>   - <span style="color: rgba(0, 0, 255, 1)">name</span>: myweb
<span style="color: rgba(0, 128, 128, 1)"> 10</span>   image: kubeguide/tomcat-app:v1
<span style="color: rgba(0, 128, 128, 1)"> 11</span>   ports:
<span style="color: rgba(0, 128, 128, 1)"> 12</span>   - containerPort: 8080
<span style="color: rgba(0, 128, 128, 1)"> 13</span>   livenessProbe:
<span style="color: rgba(0, 128, 128, 1)"> 14</span>       exec:
<span style="color: rgba(0, 128, 128, 1)"> 15</span>         command:
<span style="color: rgba(0, 128, 128, 1)"> 16</span>         - cat
<span style="color: rgba(0, 128, 128, 1)"> 17</span>         - /tmp/health
<span style="color: rgba(0, 128, 128, 1)"> 18</span>       initialDelaySeconds: 5
<span style="color: rgba(0, 128, 128, 1)"> 19</span>       timeoutSeconds: 1
<span style="color: rgba(0, 128, 128, 1)"> 20</span> <span style="color: rgba(0, 128, 0, 1)">#kubelet在容器中执行“cat /tmp/health”命令,如果该命令返回的值为0,则表明容器处于健康状态,否则表明容器处于不健康状态。</span></pre></div></font></div><font face="微软雅黑" size="2">
</font><h3 align="left">4.3        ReadinessProbe探针</h3><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; text-indent: 28px; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">另一类是ReadinessProbe探针,用于判断容器是否启动完成,且准备接收请求。如果ReadinessProbe探针检测到容器启动失败,则Pod的状态将被修改,Endpoint Controller将从Service的Endpoint中删除包含该容器所在Pod的IP地址的Endpoint条目。</font></div><font face="微软雅黑" size="2">
</font><h2 align="left">五        cAdvisor资源监控</h2><font face="微软雅黑" size="2">
</font><h3 align="left">5.1        cAdvisor概览</h3><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; text-indent: 28px; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">在Kubernetes集群中,应用程序生命周期内的信息可以在不同的级别上进行监测,如:容器、Pod、Service和整个集群。</font></div><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; text-indent: 28px; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">Kubernetes尽可能提供用户详细的各个级别的资源使用信息,从而能深入地了解应用的执行情况,并找到应用中可能的瓶颈。</font></div><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; text-indent: 28px; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">cAdvisor是一个开源的分析容器资源使用率和性能特性的代理工具,它是因为容器而产生的,因此也支持Docker容器。在Kubernetes项目中,cAdvisor被集成到Kubernetes代码中,kubelet则通过cAdvisor获取其所在节点及容器的数据</font></div><font face="微软雅黑" size="2">
</font><h3 align="left">5.2        cAdvisor原理及作用</h3><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; text-indent: 28px; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">cAdvisor自动查找所有在其所在Node上的容器,自动采集CPU、内存、文件系统和网络使用的统计信息。通常cAdvisor通过它所在Node的4194端口暴露一个简单的UI。</font></div><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; text-indent: 28px; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">kubelet作为连接Kubernetes Master和各Node之间的桥梁,管理运行在Node上的Pod和容器。kubelet将每个Pod都转换成它的成员容器,同时从cAdvisor获取单独的容器使用统计信息,然后通过该REST API暴露这些聚合后的Pod资源使用的统计信息。</font></div><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; text-indent: 28px; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">cAdvisor只能提供2~3min的监控数据,对性能数据也没有持久化,因此在Kubernetes早期版本中需要依靠Heapster来实现集群范围内全部容器性能指标的采集和查询功能。</font></div><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; text-indent: 28px; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">从Kubernetes1.8版本开始,性能指标数据的查询接口升级为标准的Metrics API,后端服务则升级为全新的Metrics Server。因此,cAdvisor在4194端口提供的UI和API服务从Kubernetes1.10版本开始进入弃用流程,并于1.12版本完全关闭。</font></div><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; text-indent: 28px; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">若需要重新启用该服务,可手动部署一个DaemonSet在每个Node上启动一个cAdvisor来提供UI和API,参考:https://github.com/google/cadvisor。</font></div><font face="微软雅黑" size="2">
</font><div align="left" style="line-height: 1.75; text-indent: 28px; white-space: pre-wrap; -ms-word-break: normal" yne-bulb-block="paragraph"><font face="微软雅黑" size="2">在新的Kubernetes监控体系中,Metrics Server用于提供CoreMetrics(核心指标),包括Node和Pod的CPU和内存使用数据。其他CustomMetrics(自定义指标)则由第三方组件(如Prometheus)采集和存储。</font></div>

</div>
<div id="MySignature" role="contentinfo">
    <div style="background: #f7acbc; color: #0; font-size: small">
<p>
作者:木二
</p>
<p>
出处:http://www.cnblogs.com/itzgr/
</p>
<p>
关于作者:云计算、虚拟化,Linux,多多交流!
</p>
<p>
本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接!如有其他问题,可邮件(xhy@itzgr.com)咨询。
</p>
</div><br><br>
来源:https://www.cnblogs.com/itzgr/p/12516417.html
頁: [1]
查看完整版本: 031.Kubernetes核心组件-kubelet