Coder Social home page Coder Social logo

k8s-monitor's Introduction

K8S集成Prometheus与EFK

背景

最近在做K8S的私有云项目建设,集群搭建功能基本完善,但是监控系统一直空缺,主要包括资源和日志两部分。看到部分私有云厂商使用了Prometheus来做资源的监控,包括网络、CPU、Memory等资源,所以私下也搭建了Prometheus集成K8S。

前置条件

K8S集群搭建完成,服务均正常运行

一、Prometheus

1.安装Prometheus

1.创建命名空间monitoring
kubectl create -f namespace.yaml
2.创建权限
kubectl create -f rbac.yaml
2.创建 node-exporter
kubectl create -f prometheus-node-exporter-daemonset.yaml
kubectl create -f prometheus-node-exporter-service.yaml
3.创建 kube-state-metrics
kubectl create -f kube-state-metrics-deployment.yaml
kubectl create -f kube-state-metrics-service.yaml
4.创建 node-directory-size-metrics
kubectl create -f node-directory-size-metrics-daemonset.yaml
5.创建 prometheus
kubectl create -f prometheus-pvc.yaml
kubectl create -f prometheus-core-configmap.yaml
kubectl create -f prometheus-core-deployment.yaml
kubectl create -f prometheus-core-service.yaml
kubectl create -f prometheus-rules-configmap.yaml

2.安装Grafana

1.安装grafana service
kubectl create -f grafana-svc.yaml
2.创建configmap
kubectl create -f grafana-configmap.yaml
3.创建pvc
kubectl create -f grafana-pvc.yaml
4.创建gragana deployment
kubectl create -f grafana-deployment.yaml
5.创建dashboard configmap
kubectl create configmap "grafana-import-dashboards" --from-file=dashboards/ --namespace=monitoring
6.创建job,导入dashboard等数据
 kubectl create -f grafana-job.yaml

二、EFK(Elasticsearch + Fluentd + Kibana)

EFK的安装方式参考 https://github.com/gjmzj/kubeasz/tree/master/manifests/efk,唯一需要注意的是Docker启动方式中,log-driver需要改成json-file的格式。
另外,安装Fluentd的时候,需要设置label,
kubectl label nodes XXXX beta.kubernetes.io/fluentd-ds-ready=true

相关文档:

https://www.cnblogs.com/163yun/p/7716253.html

https://www.cnblogs.com/sfnz/p/6566951.html

https://blog.csdn.net/wenwst/article/details/76624019

https://github.com/prometheus

https://prometheus.io/docs/

https://grafana.com

https://grafana.com/dashboards

https://github.com/gjmzj/kubeasz

https://github.com/giantswarm/kubernetes-prometheus

http://blog.51cto.com/xujpxm/2055970

http://yunlzheng.github.io/2018/03/12/prometheus-alertmanager-ha/

k8s-monitor's People

Stargazers

 avatar nevermore-muyi avatar

Watchers

nevermore-muyi avatar irying avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.