> For the complete documentation index, see [llms.txt](https://moluo.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://moluo.gitbook.io/notes/bian-cheng-xue-xi/bu-shu-yun-wei-xu-ni-hua/kubernetes/7.-rong-qi-de-ji-ben-jian-kong.md).

# 7.容器的基本监控

容器中运行的进程：docker top&#x20;

容器的系统占用状态：docker stats

图形化监控工具——weavescope

scope lauch 192.168.99

## 运行资源监控——heapster+Grafana+InfulxDB

wrk -t12 -c 400 -d30s http：//192.168.

## 根据资源占用自动横向扩展

kubectl run php-apache --image=k8s.gcr.ip/hpa-example --requests=cpu=100m --expose --port=80

kubectl autoscale deployment php-apache --cpu-percent=50 --min=1 --max=10

获取水平扩展：kubectl ger horizontalpodautoscaler

while true;do wget -q -o- <http://10.105.138.235;done>

## Log的采集和展示

ELK Stack（ElasticSearch+Logstash+Kibana）

hosted log服务

* Fluentd（log转发）
* ElasticSearch（log Index）
* Kibana（log可视化）
* LogTrail（log UI查看）

为所有节点打lable（Fluentd需要）：kubectl label node --all beta.kubernetes.io/fluentd-ds-ready=true

创建logging目录下的所有资源：kubectl create -f logging/

在kubernetes/kubernetes源码的cluster/fluentd-elasticsearch目录中可以找到Log采集和展示需要的yaml文件（es，fluentd，kibana）

## K8s集群监控方案Prometheus

pull方式
