zoukankan      html  css  js  c++  java
  • k8s集群容器监控

    硬件环境:

    两台虚拟机,

    10.10.20.203 部署docker、etcd、flannel、kube-apiserver、kube-controller-manager、kube-scheduler、influxdb、grafana

    10.10.20.206 部署docker、flannel、kubelet、kube-proxy、cadvisor

    10.10.20.207 部署docker、flannel、kubelet、kube-proxy、cadvisor

    【安装influxdb】

    1、添加yum源,执行如下指令:

    cat <<EOF | sudo tee /etc/yum.repos.d/influxdb.repo,添加以下内容

    [influxdb]
    name = InfluxDB Repository - RHEL $releasever
    baseurl = https://repos.influxdata.com/rhel/$releasever/$basearch/stable
    enabled = 1
    gpgcheck = 1
    gpgkey = https://repos.influxdata.com/influxdb.key
    EOF

    2、安装influxdb

    yum install influxdb

    3、重启服务

    systemctl enable influxdb
    systemctl start influxdb
    systemctl status influxdb

    4、编辑配置文件(查看配置文件路径,可以执行rpm -qc influxdb)

    vi /etc/influxdb/influxdb.conf

    将hostname修改为本机IP

    hostname = "10.10.20.203"

    5、创建库和用户,执行以下指令

    influx
    
    CREATE DATABASE testdb
    
    SHOW DATABASES
    
    use testdb
    
    Using database testdb
    
    CREATE USER "root" WITH PASSWORD 'root' WITH ALL PRIVILEGES
    
    show users

    【grafana】

    1、下载grafana,需要翻墙,地址为https://grafanarel.s3.amazonaws.com/builds/grafana-2.6.0-1.x86_64.rpm

    2、安装grafana,rpm -ivh grafana-2.6.0-1.x86_64.rpm

    3、重启服务

    systemctl enable grafana-server
    systemctl start grafana-server
    systemctl status grafana-server

    4、访问http://10.10.20.203:3000,用户名密码:admin/admin

    5、添加数据源,连接testdb

    【cadvisor】

    在需要监控的服务器上安装cadvisor,执行以下指令

    docker run -d 
    --volume=/:/rootfs:ro 
    --volume=/var/run:/var/run:rw 
    --volume=/sys:/sys:ro 
    --volume=/var/lib/docker/:/var/lib/docker:ro 
    --publish=8080:8080 
    --detach=true 
    --name=k8s-slave1-206-monitor 
    10.10.20.201/library/cadvisor:v1 
    -storage_driver=influxdb 
    -storage_driver_db=k8s 
    -storage_driver_host=10.10.20.203:8086

    所有软件都已经安装完毕,可以在grafana上制定dashborad了。

  • 相关阅读:
    如何不传入对象就获得某对象的方法---ThreadLocal类
    Linux系统主目录被更改,怎么修改回去?
    tree命令的安装
    Linux命令学习man
    当重载函数的参数是Object和Object数组的时候会发生什么情况!!!
    Linux学习(二)之内核、系统调用、库
    使用puttygen转换OpenSSH SSH2私钥为RSA PEM格式
    docker-compose使用详解
    svn迁移到gitlab
    linux快速启动http端口
  • 原文地址:https://www.cnblogs.com/puroc/p/5822498.html
Copyright © 2011-2022 走看看